Skip to content

Per-user auth + metering for hosted Open Score (beyond single shared token) #32

@hammadtq

Description

@hammadtq

Context

The hosted verdict API (score.attach.dev) currently authenticates with a single shared Bearer token (ATTACH_OPEN_SCORE_API_TOKEN). That is acceptable for the current standalone / small-trusted-set usage (Guard "Mode B", see attach-guard/docs/SETUP_MODES.md), but it does not scale to many managed users: whoever holds the token has full access, there's no per-caller identity, no per-user revocation, and no per-user metering.

This issue tracks the design for moving beyond one shared token. Not urgent — single token is fine for now; capturing the plan so Mode A (managed setup via Attach Platform) can scale later.

Goals (later)

  • AuthN — per-user/per-org identity. Replace the single shared secret with credentials that identify the caller.
  • Metering / quota. Per-identity request accounting and limits (today rate limiting is per-IP only).
  • Revocation. Revoke one user/org without rotating everyone's access.
  • Attribution. Know who is calling for usage/debugging.
  • (Optional, later) AuthZ / RBAC. Only if distinct actions or tiers emerge (privileged ops, plan-gated policy profiles, org admin controls). Not needed for the current single read-only /v0/verdict surface.

Candidate approaches

  1. Platform-signed JWTs (preferred direction). Attach Platform issues short-lived JWTs carrying sub (user), org, scope/plan, exp. The score service verifies the signature locally (no per-request DB lookup); revocation via short expiry + refresh. scope is where future RBAC plugs in.
  2. Shared keystore / opaque tokens. Service validates opaque tokens against a store (DB/Redis). Simpler to reason about; adds a lookup + state to the service.

Service-side changes implied

  • internal/packageverdict/server.go: auth middleware accepts validated identities instead of a single constant-time compare.
  • Per-identity metering layer (quota counters keyed by sub/org).
  • Likely a join with attach-platform for issuance + revocation.

Out of scope (for now)

  • Implementation. Single shared token stays as-is until this is scheduled.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions