Skip to content

PL-0506: RFC 9207 iss, invalid_grant re-sign-in, server audience - #114

Merged
Sekiph82 merged 4 commits into
mainfrom
feat/pl-0506-signin-hardening
Dec 3, 2026
Merged

Sekiph82 merged 4 commits into
mainfrom
feat/pl-0506-signin-hardening

Conversation

@Sekiph82

@Sekiph82 Sekiph82 commented Dec 3, 2026 •

Copy link
Copy Markdown
Owner

PL-0506 desktop sign-in hardening (open items from M21 STATE lines). Mock IdP only; no real IdP/ERP calls. PL-0506 stays open (real IdP E3).

(a) RFC 9207 - sign_in checks iss in the authorization answer before using it: when present it must equal endpoints.issuer exactly, otherwise idp_issuer_mismatch; discover reads authorization_response_iss_parameter_supported (only literal true), and then a missing iss is refused too. The loopback receiver keeps blank values so iss= cannot slip through as "absent".

(b) invalid_grant - TokenSource on token_refused: invalid_grant (new INVALID_GRANT) drops the refresh token in memory and calls on_refresh with refresh_token=None; the Warehouse page's keep() then deletes the DPAPI file (same session lock/check as saves). The next call raises signin_required without contacting the IdP (no loop); the existing status handling stops sync and asks to sign in again. Other errors (unreachable, 5xx) keep the token. resume_sign_in now deletes the saved sign-in only on invalid_grant (before: any token_refused/idp_discovery_failed, i.e. also a 503).

(c) audience - new Warehouse field "Server audience" (server.json key server_audience), passed to sign_in(audience=...) only when set (Auth0-style IdPs, matching the server's --oidc audience); empty sends no audience (Keycloak via client scopes). ERP keeps ERP_AUDIENCE.

Tests: tests/core/test_desktop_signin.py (+6 parametrized RFC 9207 cases, +1 invalid_grant/503), tests/studio/test_warehouse_view.py (+audience, +refused refresh / 503 resume with DPAPI). Local: sign-in/secure-store/warehouse/oidc 62 passed; ruff, mypy (352 files), data guard PASS.

🤖 Generated with Claude Code

Sekiph82 and others added 4 commits December 4, 2026 01:50
… audience

- sign_in refuses an authorization answer whose iss differs from the issuer, and a
  missing iss when discovery advertises authorization_response_iss_parameter_supported
- TokenSource drops the refresh token on invalid_grant (on_refresh sees None, the
  Warehouse page deletes the DPAPI copy, the next call is signin_required without an
  IdP call); other refresh errors keep it; resume deletes only on invalid_grant
- Warehouse page "Server audience" setting (server.json server_audience) passed to
  sign_in only when set (Auth0); empty sends none (Keycloak scopes)
- mock IdP tests for each item

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…l tests, resume delete under session lock

- F1: RFC 9207 cases with an error answer (wrong iss; missing iss when advertised)
- F2: an old token source's invalid_grant never deletes a newer saved sign-in
- F3: resume takes a session snapshot and deletes on invalid_grant only under
  _session_lock while that session is still current; test included

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Sekiph82
Sekiph82 merged commit ce367d3 into main Dec 3, 2026
2 checks passed
@Sekiph82
Sekiph82 deleted the feat/pl-0506-signin-hardening branch December 3, 2026 23:32
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.

1 participant