Repository navigation
endpoints/agent: return 400 instead of 500 for invalid Platform SSO token requests - #24588
Conversation
✅ Deploy Preview for authentik-storybook ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for authentik-integrations ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for authentik-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #24588 +/- ##
==========================================
- Coverage 91.20% 91.16% -0.04%
==========================================
Files 1128 1128
Lines 70501 70526 +25
Branches 3798 3798
==========================================
- Hits 64302 64297 -5
- Misses 6164 6194 +30
Partials 35 35
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
|
🍒 Cherry-pick to |
|
🍒 Cherry-pick to |
|
authentik PR Installation instructions Instructions for docker-composeAdd the following block to your AUTHENTIK_IMAGE=ghcr.io/goauthentik/dev-server
AUTHENTIK_TAG=gh-6764c57577c78ae8065fdc47ba410f8ff9d34ee7
AUTHENTIK_OUTPOSTS__CONTAINER_IMAGE_BASE=ghcr.io/goauthentik/dev-%(type)s:gh-%(build_hash)sAfterwards, run the upgrade commands from the latest release notes. Instructions for KubernetesAdd the following block to your authentik:
outposts:
container_image_base: ghcr.io/goauthentik/dev-%(type)s:gh-%(build_hash)s
global:
image:
repository: ghcr.io/goauthentik/dev-server
tag: gh-6764c57577c78ae8065fdc47ba410f8ff9d34ee7Afterwards, run the upgrade commands from the latest release notes. |
…oken requests (cherry-pick #24588 to version-2026.8) (#24593) endpoints/agent: return 400 instead of 500 for invalid Platform SSO token requests (#24588) Co-authored-by: Connor Peshek <[email protected]>
…oken requests (cherry-pick #24588 to version-2026.5) (#24592) endpoints/agent: return 400 instead of 500 for invalid Platform SSO token requests (#24588) Co-authored-by: Connor Peshek <[email protected]>
Details
What does this PR change?
Two error-handling fixes in the Platform SSO token endpoint:
validate_request_token()used the result of a.first()lookup without checking it. Anassertion whose
kidmatches noAgentDeviceConnectionraisedAttributeError: 'NoneType' object has no attribute 'connector'. It now logs theunmatched key ID and returns
None, andpost()turns that into a 400.TokenViewis a plain DjangoView, so DRF's exception handler never runs and theValidationErrors raised throughout the class escaped as HTTP 500. Adispatch()override now catches them and returns 400.
Why is this change needed?
Both cases are client errors — an unknown key ID, a device with no Secure Enclave key
registered, a replayed nonce — but they surfaced as 500s. That points debugging at the
server rather than at the device's registration state, and it makes them indistinguishable
from genuine faults in logs and monitoring.
How was this tested?
Observed against a live macOS 26.6 device with authentik Agent 0.50.5: a device whose
binding carried no enclave key produced
POST /endpoints/agent/psso/token/ -> 500withValidationError('Invalid request'), fromCould not find device user binding or independent enclave for user.Two regression tests were added to
TestAppleToken: one for an assertion signed with anunknown
kid, one for a device with no enclave key registered. Both assert 400.Linked issues
Checklist
make all)make docs)