Repository navigation
fix(auth): trust mpass identity headers only from the edge and verify the token - #58
Merged
Merged
Conversation
… the token ProxyAuthMiddleware now ignores X-Auth-Request-* unless the request carries MPASS_EDGE_SECRET in X-Mpass-Edge-Secret, which Traefik injects on the SSO router. With SMB_CORPORATE_ID set, the forwarded token is verified against the Cognito and mpass-auth-proxy JWKS (issuer, expiry, audience) instead of being decoded unverified (FOSS-776).
…ty logs Requests through Traefik carry X-Mpass-Edge-Secret and X-Auth-Request-Access-Token; API-key calls (plane-mcp) would otherwise persist both in api_activity_logs (FOSS-776).
…s errors Adds MPASS_COGNITO_ISSUER_URL (region and pool id are the fallback), ignores CHANGE_ME_ placeholders, logs an error when the corporate gate has no issuer or client id, maps non-JSON or reset JWKS fetches to a 403, and backs off 30s per issuer after a failed fetch with a 2s timeout (FOSS-776).
This was referenced Nov 12, 2026
Merged
…ion refresh wait for in-flight jwks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
MPASS_EDGE_SECRETthe new image ignores every identity header and nobody can sign in through mPass.ProxyAuthMiddlewarelogged in whoeverX-Auth-Request-Emailnamed on any request reaching plane-api, including direct calls on the Dockerbackendnetwork that skip Traefik._check_corporate_iddecoded the token withverify_signature: False, so a forged token passed too.authentication/middleware/edge_trust.py(new):request_is_from_edgecomparesX-Mpass-Edge-SecretwithMPASS_EDGE_SECRETusinghmac.compare_digest. An empty or shorter-than-32 secret trusts nothing (fail closed, like ERPNext).authentication/middleware/proxy_auth.py:_read_trusted_proxy_emailreturns an empty email), so a forged header can neither log anyone in nor trigger the user-switch logout._check_corporate_idis replaced by_corporate_rejection, which goes through the verifier below.SMB_CORPORATE_IDis set but the verifier has no issuer or client id.authentication/middleware/mpass_token.py(new):MpassTokenVerifier.MPASS_COGNITO_ISSUER_URL(the bundle passesOIDC_BASE_URI, the issuer oauth2-proxy validates), falling back toCOGNITO_AWS_REGION+COGNITO_USER_POOL_ID, plus the optionalMPASS_TOKEN_ISSUER_URLfor id_tokens re-signed by mpass-auth-proxy when email capture is on.CHANGE_ME_values count as unset.PyJWKClientper issuer, 2s fetch timeout, 30s backoff per issuer after a failed fetch.exp,iat,iss,token_userequired; 60s leeway. Access tokens needclient_id == MPASS_OIDC_CLIENT_ID, id_tokens need it inaud.bad_signature,untrusted_issuer,jwks_unavailable,wrong_organization, ...). A non-JSON JWKS body or a dropped connection isjwks_unavailable, not a 500.SMB_CORPORATE_IDunset no token is read and no JWKS is fetched, as before.middleware/logger.py:x-mpass-edge-secretandx-auth-request-access-tokenare redacted inapi_activity_logs. plane-mcp's/api/v1calls go through Traefik and would otherwise store both.settings/common.py: the new settings above.X-Api-Keycallers (plane-mcp's/api/v1leg, internal services), session cookies, god-mode and the bypass paths.Testing
pytest plane/tests/unit/middleware/test_logger.py plane/authentication/tests/ -o addopts="--strict-markers --nomigrations": 125 passed.ruff checkandruff formatclean.CHANGE_ME_handling, the startup ERROR, JWKS caching, backoff and fetch errors.GET http://plane-api:8000/api/users/me/and viaplane-proxy:80from another backend container with a forgedX-Auth-Request-Email: 401 (was 200), no user created./api/users/me/returns 200;/god-mode/and/api/instances/return 200.X-Api-Keycall to/api/v1/users/me/with a forged email header: 200 as the key owner.SMB_CORPORATE_ID, a fresh browser login was refused withreason=wrong_organization, which is only reached after the real token passed signature, issuer, expiry and audience checks against the live Cognito JWKS.