[Bug]: OIDC auth rejects all tokens from IdPs whose issuer ends with a trailing slash (Authentik, Auth0)
Issue Origin
Observed or reproduced in a real environment.
AI-use disclosure: this bug was found and reproduced by an AI coding agent (Claude Code) working at the direction of the human filer. The reproduction is a real runtime execution inside the official Docker image, not a static-code inference; the observed output appears under Error Logs, and the human filer reviewed the finding and this report before submitting.
Bug Description
OIDC authentication cannot work against identity providers that mint iss with a trailing slash; Authentik and Auth0 both do. The issuer field validator strips trailing slashes from the configured value, while token validation relies on python-jose's exact-match issuer check, so no configuration value can match tokens from these providers.
Steps to Reproduce
- Save the script from the Minimal Reproducible Example below as
repro.py. - Run it inside the official image:
podman run --rm -v "$PWD:/t:ro" --entrypoint /app/.venv/bin/python ghcr.io/volcengine/openviking:v0.5.0 /t/repro.py
Expected Behavior
Configuring the issuer exactly as it appears in tokens (Authentik's form, https://authentik.example/application/o/myapp/) authenticates successfully.
Actual Behavior
OIDCConfig(issuer=".../myapp/") stores .../myapp (the validator rstrips), and every token from a slashed-issuer IdP fails with JWTClaimsError: Invalid issuer. Unslashed-issuer IdPs (Keycloak, Okta, Azure AD) are unaffected, which is likely why tests do not catch it.
Minimal Reproducible Example
from openviking.server.auth.oidc_config import OIDCConfig
from jose import jwt
# 1) the validator strips the trailing slash: a slashed issuer cannot be configured
cfg = OIDCConfig(issuer="https://authentik.example/application/o/myapp/")
print(cfg.issuer) # -> 'https://authentik.example/application/o/myapp'
# 2) python-jose compares exactly, so an Authentik-shaped token can never pass
key = "demo"
tok = jwt.encode({"iss": "https://authentik.example/application/o/myapp/", "sub": "u"}, key, algorithm="HS256")
jwt.decode(tok, key, algorithms=["HS256"], issuer=cfg.issuer)
# -> jose.exceptions.JWTClaimsError: Invalid issuer
Error Logs
jose.exceptions.JWTClaimsError: Invalid issuer
Runtime-observed inside ghcr.io/volcengine/openviking:v0.5.0, digest sha256:9e0a87c15ded8f8d7eca68d8b7213c8f54e258caa2f7d04e54ceb995fcc8b31e.
OpenViking Version
0.5.0 (also present on current main: openviking/server/auth/oidc_config.py, validate_issuer, the v.rstrip("/") line)
Python Version
3.13 (image base: python:3.13-slim)
Operating System
Linux (official container)
Model Backend
Other (authentication path only)
Additional Context
Root cause: the normalization direction of @field_validator("issuer") versus python-jose's exact-match _validate_iss. Two candidate fixes:
- (a) keep the configured issuer exactly as given (drop the rstrip) and document exact-match semantics;
- (b) normalize both sides at comparison time (rstrip the incoming token's
issas well), which keeps existing unslashed configs working while making slashed-issuer IdPs usable.
Happy to send a PR for either if maintainers have a preference. Authentik tested: 2026.8.3; its issuer URL always carries the trailing slash.
I reproduced this on current main and opened #6254: https://github.com/volcengine/OpenViking/pull/6254
The fix keeps the normalized value for discovery URL construction and compares
the token iss against the configured issuer with one trailing slash ignored,
so existing unslashed configurations keep working. Audience and expiry
validation are unchanged. Happy to adjust if maintainers prefer strict
exact-match semantics instead.