Skip to content

endpoints/agent: fix Secure Enclave key dropped on first Platform SSO user registration - #24587

Merged
PeshekDotDev merged 1 commit into
mainfrom
endpoints/agent-psso-enclave-key
Jul 31, 2026
Merged

PeshekDotDev merged 1 commit into
mainfrom
endpoints/agent-psso-enclave-key

Conversation

@PeshekDotDev

Copy link
Copy Markdown
Contributor

Details

What does this PR change?

RegisterUserView passed the Secure Enclave fields to update_or_create() in defaults
only, with create_defaults holding just is_primary and order. Django's
update_or_create() returns immediately when it creates the object, so defaults is never
applied on the create path — the enclave key and key ID were silently discarded the first
time a user registered, and the endpoint still returned 200.

The fields are now passed in both create_defaults and defaults.

test_register_user previously asserted only the response status and username, which is why
this went unnoticed. It now asserts that the enclave key and key ID are persisted on create,
and that re-registering replaces them.

Why is this change needed?

Platform SSO is unusable after a first-time registration. The binding is written with an
empty apple_enclave_key_id, so validate_embedded_assertion() in apple_token.py cannot
match the assertion to a binding or an independent enclave, and the token exchange fails.

The bug only bites on the create path — a second registration takes the update branch, where
defaults does apply and the key is written correctly. That makes it easy to miss in manual
testing and is likely why it survived review.

How was this tested?

Reproduced end to end against a live macOS 26.6 device with authentik Agent 0.50.5, before
applying the fix:

  • POST /api/v3/endpoints/agents/psso/register/user/ → 200
  • the resulting binding had apple_enclave_key_id = '' and a zero-length
    apple_secure_enclave_key
  • the next POST /endpoints/agent/psso/token/ failed, logging
    Could not find device user binding or independent enclave for user

Linked issues


Checklist

  • The project has been linted, built, and tested (make all)
  • The documentation has been updated and formatted (make docs)

@PeshekDotDev
PeshekDotDev requested a review from BeryJu July 31, 2026 16:45
@PeshekDotDev PeshekDotDev self-assigned this Jul 31, 2026
@PeshekDotDev
PeshekDotDev requested a review from a team as a code owner July 31, 2026 16:45
@netlify

netlify Bot commented Jul 31, 2026

Copy link
Copy Markdown

✅ Deploy Preview for authentik-storybook ready!

Name Link
🔨 Latest commit 296443c
🔍 Latest deploy log https://app.netlify.com/projects/authentik-storybook/deploys/6a6cd1465825de0008407d53
😎 Deploy Preview https://deploy-preview-24587--authentik-storybook.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify

netlify Bot commented Jul 31, 2026

Copy link
Copy Markdown

✅ Deploy Preview for authentik-integrations ready!

Name Link
🔨 Latest commit 296443c
🔍 Latest deploy log https://app.netlify.com/projects/authentik-integrations/deploys/6a6cd14621e6ba000857e435
😎 Deploy Preview https://deploy-preview-24587--authentik-integrations.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify

netlify Bot commented Jul 31, 2026

Copy link
Copy Markdown

✅ Deploy Preview for authentik-docs ready!

Name Link
🔨 Latest commit 296443c
🔍 Latest deploy log https://app.netlify.com/projects/authentik-docs/deploys/6a6cd14641c0e200084a72b2
😎 Deploy Preview https://deploy-preview-24587--authentik-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@PeshekDotDev PeshekDotDev added backport/version-2026.5 Add this label to PRs to backport changes to version-2026.5 backport/version-2026.8 Add this label to PRs to backport changes to version-2026.8 labels Jul 31, 2026
@codecov

codecov Bot commented Jul 31, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.16%. Comparing base (00c751d) to head (296443c).
⚠️ Report is 10 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #24587      +/-   ##
==========================================
- Coverage   91.20%   91.16%   -0.05%     
==========================================
  Files        1128     1128              
  Lines       70501    70515      +14     
  Branches     3798     3798              
==========================================
- Hits        64302    64282      -20     
- Misses       6164     6198      +34     
  Partials       35       35              
Flag Coverage Δ
conformance 35.16% <0.00%> (-0.01%) ⬇️
e2e 39.95% <0.00%> (-0.02%) ⬇️
integration 31.26% <0.00%> (-0.47%) ⬇️
rust 37.78% <ø> (ø)
unit 92.87% <100.00%> (+<0.01%) ⬆️
unit-migrate 92.90% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@github-actions

Copy link
Copy Markdown
Contributor

authentik PR Installation instructions

Instructions for docker-compose

Add the following block to your .env file:

AUTHENTIK_IMAGE=ghcr.io/goauthentik/dev-server
AUTHENTIK_TAG=gh-296443c98599502e7de01cd648e9ef6449d06f29
AUTHENTIK_OUTPOSTS__CONTAINER_IMAGE_BASE=ghcr.io/goauthentik/dev-%(type)s:gh-%(build_hash)s

Afterwards, run the upgrade commands from the latest release notes.

Instructions for Kubernetes

Add the following block to your values.yml file:

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-296443c98599502e7de01cd648e9ef6449d06f29

Afterwards, run the upgrade commands from the latest release notes.

@github-project-automation github-project-automation Bot moved this from Todo to In Progress in authentik Core Jul 31, 2026
@PeshekDotDev
PeshekDotDev merged commit aea96ac into main Jul 31, 2026
126 checks passed
@PeshekDotDev
PeshekDotDev deleted the endpoints/agent-psso-enclave-key branch July 31, 2026 17:16
@github-project-automation github-project-automation Bot moved this from In Progress to Done in authentik Core Jul 31, 2026
@authentik-cherry-pick

Copy link
Copy Markdown
Contributor

🍒 Cherry-pick to version-2026.5 created: #24589

@authentik-cherry-pick

Copy link
Copy Markdown
Contributor

🍒 Cherry-pick to version-2026.8 created: #24590

PeshekDotDev added a commit that referenced this pull request Jul 31, 2026
… user registration (cherry-pick #24587 to version-2026.8) (#24590)

endpoints/agent: fix Secure Enclave key dropped on first Platform SSO user registration (#24587)

Co-authored-by: Connor Peshek <[email protected]>
PeshekDotDev added a commit that referenced this pull request Jul 31, 2026
… user registration (cherry-pick #24587 to version-2026.5) (#24589)

endpoints/agent: fix Secure Enclave key dropped on first Platform SSO user registration (#24587)

Co-authored-by: Connor Peshek <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport/version-2026.5 Add this label to PRs to backport changes to version-2026.5 backport/version-2026.8 Add this label to PRs to backport changes to version-2026.8

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants