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

Dynamic jwks based on iss and aud #638

Merged
merged 3 commits into from
Apr 16, 2023
Merged

Conversation

FZambia
Copy link
Member

@FZambia FZambia commented Apr 13, 2023

Proposed changes

More generic version of #618

It's possible to extract vars from issuer and aud JWT claims using Go regexp named groups, then use these vars to construct JWKS endpoint dynamically. In this case JWKS endpoint may be set in config as template. Let's look how this may help in case of using different realms of Keycloak:

{
  "token_issuer_regex": "https://example.com/auth/realms/(?P<realm>[A-z]+)",
  "token_jwks_public_endpoint": "https://keycloak:443/{{realm}}/protocol/openid-connect/certs"
}

Two new options introduced:

  • token_issuer_regex - match JWT issuer against this regex, extract named groups to variables for jwks endpoint construction.
  • token_audience_regex - match JWT audience against this regex, extract named groups to variables for jwks endpoint construction.

TODO:

  • when using token_issuer_regex and token_audience_regex make sure token_issuer and token_audience not used in the config - return an error on start in this case.

@FZambia
Copy link
Member Author

FZambia commented Apr 15, 2023

@matpuk hello, probably this addresses your previous comment - maybe you'll be interested to check this out.

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

Successfully merging this pull request may close these issues.

1 participant