Skip to content

Allow to configure grace period #19

@king-of-poppk

Description

@king-of-poppk

The grace period for token validation is currently hard-coded to 60 seconds, see here:

jose/R/jwt.R

Lines 171 to 188 in 429a463

# As suggested in the spec, we give a 60s grace period to account
# for inaccurate clocks.
check_expiration_time <- function(payload){
if(length(payload$exp)){
stopifnot("exp claim is a number" = is.numeric(payload$exp))
expdate <- structure(payload$exp, class = c("POSIXct", "POSIXt"))
if(expdate < (Sys.time() - 60)){
stop(paste("Token has expired on", expdate), call. = FALSE)
}
}
if(length(payload$nbf)){
stopifnot("nbf claim is a number" = is.numeric(payload$nbf))
nbfdate <- structure(payload$nbf, class = c("POSIXct", "POSIXt"))
if(nbfdate > (Sys.time() + 60)){
stop(paste("Token is not valid before", nbfdate), call. = FALSE)
}
}
}

Would it be possible to make this configurable? It would help to test the token expiration functionality.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions