Skip to content

fix(oidc): preserve configured issuer for token verification - #6962

Open
mangomac wants to merge 1 commit into
keephq:mainfrom
mangomac:oidc-issuer-trailing-slash-6934
Open

mangomac wants to merge 1 commit into
keephq:mainfrom
mangomac:oidc-issuer-trailing-slash-6934

Conversation

@mangomac

Copy link
Copy Markdown

Fixes #6934.

What

OidcAuthVerifier.__init__ stripped a trailing slash from the configured KEEP_OIDC_ISSUER, but the same value is then passed to jwt.decode(..., issuer=self.oidc_issuer) for an exact iss comparison. With an IdP whose issuer ends with a slash (e.g. Authentik), every login failed with Invalid token: Invalid issuer.

  • The issuer now reaches jwt.decode unaltered.
  • The trailing-slash normalization moves to the one place that needs it: _discover_jwks_uri now joins {issuer.rstrip('/')}/.well-known/openid-configuration, so discovery never produces a double slash. This is the same split the reporter verified in the issue.

Tests

Two regression tests in tests/test_oidc_auth.py:

  • test_oidc_issuer_trailing_slash_preserved - issuer configured with a trailing slash, token iss carries the slash, verification succeeds (previously a 401).
  • test_oidc_discovery_url_normalizes_trailing_slash - the discovery URL is single-slash-joined with and without a trailing slash on the configured issuer.

Both tests fail on main and pass with this change. Full tests/test_oidc_auth.py: 15 passed. black --check and isort --check-only clean on the touched files.

…6934)

The OidcAuthVerifier initializer stripped a trailing slash from the
configured KEEP_OIDC_ISSUER, but that same value is compared verbatim
against the token's iss claim. Providers whose issuer ends with a slash
(e.g. Authentik) therefore failed every login with 'Invalid token:
Invalid issuer'.

The issuer now reaches jwt.decode unaltered; the trailing-slash
normalization moves to the one place that needs it, the discovery URL
join in _discover_jwks_uri, so {issuer}/.well-known/openid-configuration
never gets a double slash.

Regression coverage: an issuer with a trailing slash verifies a token
whose iss carries that slash (previously a 401), and the discovery URL
is single-slash-joined with and without a trailing slash. Both tests
fail without this change.

Fixes keephq#6934
@CLAassistant

CLAassistant commented Nov 12, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

This branch has not been deployed

No deployments
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.

[🐛 Bug]: oidc_authverifier.py strips trailing slash causing "Invalid token: Invalid issuer" error

2 participants