Skip to content

feat(auth): add scoped personal access tokens - #1686

Open
hgaol wants to merge 3 commits into
apache:devfrom
hgaol:feat/pat-user-access
Open

hgaol wants to merge 3 commits into
apache:devfrom
hgaol:feat/pat-user-access

Conversation

@hgaol

@hgaol hgaol commented Nov 23, 2026

Copy link
Copy Markdown
Member

Fixes #1555

Proposed Changes

  • Add scoped, expiring personal access tokens for existing user accounts, including revocation and account settings management.
  • Add Bearer token authentication with route scopes for core actions and an admin-controlled security toggle.
  • Update API documentation and add backend and UI test coverage.

Add user-owned expiring and revocable credentials, strict Bearer authentication, semantic route scopes, current account resolution, recent-authentication checks, account lifecycle hooks, and default-off admin controls. Include account-settings management, HTTP documentation, and end-to-end coverage for two eligible users creating content and voting through PATs.
@LinkinStars

Copy link
Copy Markdown
Member

The PAT lookup selects an external login by user_id without filtering by provider, then passes its ExternalID to the active UserCenter plugin.

For example, a local account linked only to GitHub is correctly exempt from UserCenter status checks during password login, but its PAT sends the GitHub ID to UserCenter, which may produce an incorrect authentication result.

Please align this with CheckUserStatusInUserCenter: resolve the binding for the active UserCenter provider, and leave ExternalID empty when no matching binding exists.

Filter external login lookup by both user ID and the active UserCenter provider. Leave ExternalID empty when no UserCenter or matching binding exists, so unrelated OAuth identities are never sent to the plugin.

Add regression coverage for disabled UserCenter, missing bindings, unrelated and inactive providers, matching bindings, and multiple providers, including another user's binding. Addresses the review comment on apache#1686.
@hgaol

hgaol commented Nov 26, 2026 •

Copy link
Copy Markdown
Member Author

Fixed in 138b297. GetUserCacheInfoByUserID now looks up the external-login binding for the active UserCenter provider and leaves ExternalID empty if no matching binding exists. Regression tests cover disabled UserCenter, missing/unrelated/inactive bindings, matching and multiple providers, and a binding owned by another user. The focused regression test passes.

This branch has not been deployed

No deployments
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.

2 participants