[Bug]: Bearer token from `extra_jwt_issuers` does not respect `insecure_oidc_allow_unverified_email`
OAuth2-Proxy Version
7.8.2
Provider
keycloak-oidc
Expected Behaviour
Bearer token should be accepted when insecure_oidc_allow_unverified_email = true if the iss is included in the extra_jwt_issuers field and email_verified: False
Current Behaviour
When using OAuth2 Proxy with JWT bearer tokens, there's inconsistent behavior between tokens from the main OIDC issuer vs. tokens from extra_jwt_issuers
When
oidc_issuer_urlmatches the token'sissclaim:- Tokens with
email_verified: falseare accepted ifinsecure_oidc_allow_unverified_email = true. - ✅ The configuration flag functions as intended.
- Tokens with
{
"iss": "https://keycloak.com/realms/dune",
"aud": ["example_aud", "not_dune", "dune"],
"typ": "ID",
"azp": "some-client-id",
"preferred_username": "service-account-tester
"email_verified": false
}When the token's
issclaim is listed underextra_jwt_issuers:Tokens with
email_verified: falseare rejected with the following error:email in id_token (24b3d099-31e4-47bb-9839-64adef09b4ae) isn't verified❌ The
insecure_oidc_allow_unverified_emailflag has no effect in this case.
{
"iss": "https://keycloak.com/realms/not_dune",
"aud": ["example_aud", "not_dune", "dune"],
"typ": "ID",
"azp": "my-client-id",
"preferred_username": "service-account-my-client-id",
"email_verified": false
}Steps To Reproduce
Configure OAuth2 Proxy with:
skip_jwt_bearer_tokens = true oidc_issuer_url = https://keycloak.com/auth/realms/not_dune insecure_oidc_allow_unverified_email = true insecure_oidc_skip_issuer_verification = true extra_jwt_issuers = https://keycloak.com/auth/realms/dune=example_audSubmit a request with a JWT bearer token from the extra issuer that has
email_verified: falseand noemailkey present.Observe the error:
email in id_token (24b3d099-31e4-47bb-9839-64adef09b4ae) isn't verified
Possible Solutions
Modify CreateTokenToSessionFunc to accept and respect the insecure_oidc_allow_unverified_email setting. Looking at buildSessionFromClaims where it does respect the field:
verifyEmail := (p.EmailClaim == options.OIDCEmailClaim) && !p.AllowUnverifiedEmailConfiguration details or additional information
provider = "keycloak-oidc"
email_domains = "*"
upstreams = [ "http://nginx-proxy-srv:8080" ]
redirect_url = "https://example.com/oauth2/callback"
pass_access_token = true
pass_authorization_header = true
pass_user_headers = true
skip_jwt_bearer_tokens = true
insecure_oidc_allow_unverified_email = true
insecure_oidc_skip_issuer_verification = true
code_challenge_method = "S256"
cookie_name = "__Secure-oauth2_proxy"
cookie_refresh = "60s"
cookie_samesite = "none"
skip_provider_button = true
oidc_issuer_url = "https://keycloak.com/auth/realms/dune"
silence_ping_logging = true
skip_auth_routes = [ "/utils/health", "/healthz" ]
metrics_address = "0.0.0.0:9100"
extra_jwt_issuers= "https://keycloak.com/auth/realms/not_dune=example_aud"Source: oauth2-proxy/oauth2-proxy