Skip to content

feat(api): accept Bearer API tokens on GET /api/identities - #228

Merged
ChiragAgg5k merged 1 commit into
mainfrom
feat/identities-bearer
Nov 23, 2026
Merged

ChiragAgg5k merged 1 commit into
mainfrom
feat/identities-bearer

Conversation

@ChiragAgg5k

@ChiragAgg5k ChiragAgg5k commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Lets a service read the user registry with an API token, so it can mention people by their Discord or Slack handle. For example, a notifier can tag the authors of the code an alert points at. Until now, GET /api/identities only accepted a dashboard session.

Changes

  • New Caller extractor: authenticates by Authorization: Bearer <token> or, when that header is absent, by session. It is the Bearer half of AdminCaller, moved out unchanged: a present header never falls back to the cookie, and failed attempts spend the per-address bearer limit.
  • AdminCaller is now Caller plus the admin check, so PUT /api/directory behaves exactly as before.
  • GET /api/identities takes a Caller. A token sees what its user's session would see: a non-admin token gets other people redacted (no email, phone numbers, push keys or chat ids), while GitHub, Discord and Slack handles stay visible.
  • README: the Identity API section lists the endpoint as accepting Bearer.

A service should use a token from a viewer account, with an expiry, not an admin token.

Tests

  • Extended the identities list test: a viewer's API token reads the list, gets others redacted, and still sees their GitHub usernames and Discord ID.
  • cargo clippy -p claudear-engine --all-targets --all-features -- -D warnings is clean.
  • cargo test -p claudear-engine --features sqlite --lib passes for identities (36), directory (57), api::auth (76) and api::security (29).

Related: appwrite-labs/cloud#6671

A service that mentions people, such as a notifier tagging the authors of a change, needs the GitHub and Discord handles the registry holds, and only a dashboard session could read them. A token reads what its user's session would: a non-admin token gets the redacted view, which keeps those handles. Bearer and session auth now share one Caller extractor, and AdminCaller builds on it.
@appwrite

appwrite Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Code review

Commit Status Tier Verdict Details
7d005bd Reviewed Reviewed 🟢 S · Ready to merge ✅ Approved View review

The Bearer path preserves the existing token validation and failure limiting, and the identity handler applies the same visibility rules to token and session callers.

Adds a shared Caller extractor that authenticates requests with Bearer API tokens or falls back to dashboard sessions, then composes the admin check for directory writes. GET /api/identities now accepts either credential and keeps the existing role-based redaction behavior; the README and identity-list test are updated accordingly.

Walkthrough (4)
File Change
README.md Documents Bearer support for the identities listing and updates the endpoint table.
crates/claudear-engine/src/api/auth.rs Extracts general session/Bearer authentication into Caller and retains admin-only access through AdminCaller.
crates/claudear-engine/src/api/identities.rs Uses Caller for the identities list endpoint while preserving existing visibility behavior.
crates/claudear-engine/src/api/routes.rs Adds coverage for a viewer API token receiving the redacted identities list with handles available.

Reviewed 7d005bd

Tip

Comment @appwrite review to re-run, or mention @appwrite with a question.

@appwrite appwrite Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Tier S · Looks good to merge. Summary

@ChiragAgg5k
ChiragAgg5k merged commit aaa1095 into main Nov 23, 2026
20 checks passed
@ChiragAgg5k
ChiragAgg5k deleted the feat/identities-bearer branch November 23, 2026 13:06
@ChiragAgg5k ChiragAgg5k self-assigned this Nov 24, 2026
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