Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to configure grace period #19

Open
king-of-poppk opened this issue Jul 20, 2023 · 0 comments
Open

Allow to configure grace period #19

king-of-poppk opened this issue Jul 20, 2023 · 0 comments

Comments

@king-of-poppk
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant