Repository navigation
feat(auth): link SkillX accounts with AgentKit and accept its access tokens - #161
Merged
Merged
Conversation
…tokens - "Link with AgentKit" in Settings: public OAuth client (CIMD), auth code + S256 PKCE, resource https://skillx.sh/api; consent, unlink with revoke. - Resource server: agentkit.best at+jwt (ES256) verified via JWKS and mapped to library:read / kits:write:@handle on scoped-credential routes. - Link liveness re-checked by refresh every 60s; invalid_grant unlinks. - RFC 9728 metadata and WWW-Authenticate resource_metadata on 401s. - Additive migration 0021 (agentkit_links); flag SKILLX_AGENTKIT_IDENTITY stays off until the agentkit.best AS is in production. Part of #81 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…reshes - Claim a link refresh only if no other request refreshed since the row was read, so a stale read never replays a spent refresh token. - Store the rotated refresh token before verifying the new access token, and revoke it when the subject no longer matches. - Requests that lose the claim ride on the refresh in flight instead of answering 503 after a long idle period. - Refuse a link the AS issued no refresh token for. - Treat an undecodable signature as invalid_token, keep serving cached JWKS keys while a refresh fails (throttled, single-flight). - Advertise RFC 9728 metadata in 401 challenges only while the feature is on. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
5 tasks
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #81 (account linking + resource server; evidence events and webhooks stay open there).
Implements the SkillX side of the AgentKit identity contract (
identity-contract.md, v3 ecosystem linking).What changes
https://skillx.sh/oauth/client.json. It uses auth code + S256 PKCE withresource=https://skillx.sh/apiand scopesskillx-kits:read skillx-kits:write. Thestateis bound to the session user in KV (10 min), so a callback in another account's session is refused.sublinks to at most one SkillX account; a duplicate link is refused and its new grant revoked.resolveRequestCredential), an agentkit.bestat+jwtis verified locally against the JWKS (ES256,typ,iss,aud⊇ resource,exp/iat,sub) and mappedskillx-kits:read→library:read,skillx-kits:write→kits:write:@<active handle>. Errors:401 invalid_token,403 account_not_linked(with the link URL),503 agentkit_unavailable.invalid_grantdeletes the link; during an AS outage there is a 15 min grace, then503. The refresh token is stored AES-GCM encrypted (HKDF fromBETTER_AUTH_SECRET, user id as AAD)./.well-known/oauth-protected-resource[/api]. Every 401 on these routes carriesWWW-Authenticate: Bearer resource_metadata=....https://skillx.sh/apidirectly as Bearer.Safety
SKILLX_AGENTKIT_IDENTITYis"0"in production until the agentkit.best AS (ak-web #726) is deployed. With it off, bearer JWTs are ignored, the link and discovery routes answer 404, and unlinked accounts behave exactly as before.0021_agentkit_linksis additive only (a new table) and has rollback SQL in its header.Tests
tests/auth/agentkit-bearer.test.tsandagentkit-link.test.ts(32 tests) run against a fake AS with a real ES256 key, PKCE checks, rotating refresh tokens and revocation.pnpm typecheckis clean.🤖 Generated with Claude Code