Skip to content

feat(auth): add explicit delegation with legacy compatibility - #6155

Open
pandemicsyn wants to merge 1 commit into
mainfrom
split/explicit-resource-delegation
Open

feat(auth): add explicit delegation with legacy compatibility#6155
pandemicsyn wants to merge 1 commit into
mainfrom
split/explicit-resource-delegation

Conversation

@pandemicsyn

Copy link
Copy Markdown
Contributor

Summary

Add explicit, short-lived resource-token issuance for API, gateway, organization attribution, and HTML deployment. Personal requests use /api/auth/resource-token; organization requests opt in with a resource field on /api/organizations/[id]/user-tokens. Resource tokens use an exact audience and expire within 15 minutes and the source credential's remaining lifetime.

Preserve the existing organization-token response for valid browser sessions and unrestricted legacy bearers without resource negotiation, including one-hour and five-year credentials. Restricted and audience-bound credentials cannot obtain broad legacy tokens. Organization permissions and audit logging remain enforced; personal attribution is rejected.

Extracted from #5976, originating in #5857. This PR targets main independently of mobile and Chat.

Verification

No manual deployed-client smoke tests were run. Automated route tests exercise real JWT verification, database authorization, issuance, and legacy compatibility; browser-session results are substituted in the test environment.

Visual Changes

N/A

Reviewer Notes

Feature toggles Default Where to configure
DELEGATED_RESOURCE_TOKENS_ENABLED Off: unset or false Vercel — Web environment variables; redeploy Web after changes
SHARED_RESOURCE_TOKENS_ENABLED Off in code; may already be enabled for other families Vercel — Web environment variables; preserve the existing setting

New resource issuance requires both Web variables to be exactly true. No flag needs enabling at merge. Existing no-resource legacy issuance remains available with the family gate off or on. Restricted credentials are denied legacy minting in either state; this restriction is active on deployment. Disabling issuance does not revoke previously issued tokens.

Automated validation: 119 tests across 5 suites passed, plus Web typecheck, changed-file lint, formatting, and diff checks. Coverage includes legacy token lifetimes and device sessions, both flag states, organization roles and audit records, invalid/revoked credentials, restricted-token denial, and attribution route/receiver agreement.

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