Skip to content

fix: service auth token handling and did:web resolution#167

Open
rabble wants to merge 1 commit intoblacksky-algorithms:mainfrom
divinevideo:pr/auth-service-tokens-didweb
Open

fix: service auth token handling and did:web resolution#167
rabble wants to merge 1 commit intoblacksky-algorithms:mainfrom
divinevideo:pr/auth-service-tokens-didweb

Conversation

@rabble
Copy link
Copy Markdown

@rabble rabble commented Mar 29, 2026

Summary

  • Service auth fallback to repo signing key: When JWT key verification fails, try the repo signing key (PDS_REPO_SIGNING_KEY_K256_PRIVATE_KEY_HEX). This enables accepting service auth tokens from external services like video.bsky.app that sign tokens with the PDS's repo signing key rather than the JWT session key.
  • Handle missing scope/sub in service tokens: Service auth tokens from video.bsky.app use lxm instead of scope and iss instead of sub. The verifier now defaults to Access scope when scope is empty and falls back to iss when sub is absent.
  • Graceful error handling: Replace unwrap() calls on sub/aud with proper error messages instead of panics. Accept PDS_ADMIN_PASSWORD as alias for PDS_ADMIN_PASS.
  • did:web resolution: Serve /.well-known/did.json for did:web:{hostname} resolution, deriving the secp256k1 public key multibase from the PDS repo signing key. This enables service-to-service auth where the PDS identity is did:web:hostname.

Test plan

  • Verify session tokens (JWT key) still work for normal auth flows
  • Verify service auth callback from video.bsky.app is accepted (token signed with repo key, missing scope, iss instead of sub)
  • Verify GET /.well-known/did.json returns valid DID document with correct public key
  • Verify admin auth works with both PDS_ADMIN_PASSWORD and PDS_ADMIN_PASS
  • Run cargo check -p rsky-pds to verify compilation

🤖 Generated with Claude Code

…web document

Auth verifier improvements:
- Try repo signing key (PDS_REPO_SIGNING_KEY_K256_PRIVATE_KEY_HEX) as
  fallback when JWT key verification fails, enabling service auth tokens
  from external services like video.bsky.app
- Handle missing scope field in service auth tokens by defaulting to
  Access scope (service tokens use lxm instead of scope)
- Fall back to JWT issuer (iss) when subject (sub) is absent, which is
  how video.bsky.app callback tokens are structured
- Handle missing sub/aud gracefully instead of unwrap panics
- Accept PDS_ADMIN_PASSWORD as alias for PDS_ADMIN_PASS, with graceful
  error when neither is set

did:web resolution:
- Serve /.well-known/did.json for did:web:{hostname} resolution
- Derive secp256k1 public key multibase from PDS repo signing key
- Include AtprotoPersonalDataServer service endpoint

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@afbase
Copy link
Copy Markdown
Collaborator

afbase commented Apr 12, 2026

relates to #171

@afbase afbase self-requested a review April 12, 2026 21:01
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