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

jwt validation is very slow #104

Open
roee-hersh opened this issue Aug 31, 2023 · 2 comments
Open

jwt validation is very slow #104

roee-hersh opened this issue Aug 31, 2023 · 2 comments

Comments

@roee-hersh
Copy link

adding the following code:

tv := map[string]string{}
	tv["aud"] = "api://default"
	tv["cid"] = utils.Config.OktaClientID

	jv := verifier.JwtVerifier{
		Issuer:           utils.Config.OktaIssuer,
		ClaimsToValidate: tv,
	}

	result, err := jv.New().VerifyAccessToken(t)

cause every requests which normally takes less then 100MS to take over 1-2 seconds.
is this normal? is there a way to improve it?

@roee-hersh roee-hersh changed the title validation is very slow jwt validation is very slow Aug 31, 2023
@Sovietaced
Copy link

I've been seeing similar behavior where P50 for token validation is very low (sub ms) but the P99 for token validation is 5-10 seconds. I believe this has to do with the default behavior of the cache mechanism which blocks the verification inline while it retrieves the latest trusted signature keys (via HTTP request to Okta).

@Sovietaced
Copy link

I ended up writing my own Okta JWT verifier with support for fetching OIDC metadata and JWK sets asynchronously in the background as to not block and slowdown the verification calls: https://github.com/Sovietaced/okta-jwt-verifier

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

2 participants