R/nonce.R

Defines functions set_nonce get_nonce acme_new_nonce bail

# A nonce should be included with each POST to protect against replay attacks
NONCE <- NULL

set_nonce <- function(nonce){
  NONCE <<- nonce
}

get_nonce <- function(){
  if(!length(NONCE))
    acme_new_nonce()
  if(!length(NONCE))
    bail("Failed to get new nonce")
  nonce <- NONCE
  set_nonce(NULL)
  return(nonce)
}

acme_new_nonce <- function(){
  HEAD("/acme/new-nonce")
}

bail <- function(...){
  stop(sprintf(...), call. = FALSE)
}
ropensci/acme documentation built on May 20, 2019, 9:16 p.m.