Skip to content

Implement a secure signed capability token codec for internal GuildPass authorisation #371

Description

@Lakes41

Difficulty: Expert
Type: Feature
Recommended labels (if available in this repo): security, access-control, backend, expert

Background

GuildPass may need to represent short-lived internal authorisation capabilities that can be passed between trusted components without requiring each consumer to query a central store for every operation.

This issue introduces a generic signed capability token primitive only. It is not an authentication system and must not replace user sessions or wallet authentication.

Problem

There is currently no standard Core mechanism for issuing and verifying compact, tamper-evident capability payloads with clear expiry and scope semantics.

A poorly designed token can be replayed indefinitely, modified by clients or accepted outside its intended audience.

Expected Outcome

Build a dependency-light capability token codec that signs a constrained payload and verifies integrity, expiry, audience and optional scope requirements.

Suggested Implementation

Define a payload similar to:

interface CapabilityPayload {
  version: 1;
  subject: string;
  audience: string;
  scopes: string[];
  issuedAt: number;
  expiresAt: number;
  nonce: string;
}

The implementation should:

  • encode payloads into a URL-safe token;
  • sign the token using HMAC-SHA256 or another justified symmetric mechanism;
  • accept the secret/key through explicit configuration;
  • reject modified payloads or signatures;
  • verify expiry;
  • reject tokens issued unreasonably far in the future;
  • enforce an expected audience;
  • optionally enforce required scopes;
  • validate payload shape at runtime;
  • support token versioning;
  • impose maximum token size;
  • use timing-safe signature comparison;
  • avoid storing token state in a database;
  • clearly document that revocation is outside the scope of this primitive.

Acceptance Criteria

  • Valid signed capability tokens can be issued and verified.
  • Payload tampering causes verification failure.
  • Signature tampering causes verification failure.
  • Expired tokens are rejected.
  • Future-dated tokens beyond an allowed tolerance are rejected.
  • Audience mismatches are rejected.
  • Required-scope checks behave deterministically.
  • Unsupported token versions are rejected.
  • Malformed payloads fail safely.
  • Signature comparison is timing-safe.
  • Secrets are never hard-coded or emitted in errors.
  • Unit tests include fixed deterministic vectors.
  • pnpm typecheck passes.
  • pnpm build passes.
  • pnpm test passes.
  • No session, wallet-authentication or persistence feature is introduced.

Likely Affected Files/Directories

packages/capability-token/ or equivalent isolated package
unit tests

Independence Requirement

This issue must be independently implementable from main and must not rely on an authentication, membership or API issue being completed first.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

GrantFox OSSGrantFox Open Source Sponsorship program tagMaybe RewardedIssue may qualify for a reward upon successful completion per campaign rulesThird CampaignOfficial FWC26 campaign issue — eligible for campaign scoring and rewardsaccess-controlAccess evaluation, permissions, authorisation rules, and protected resource logicbackendBackend services, application logic, persistence integration, and server-side functionalityexpertExpert difficulty tasks requiring deep expertise and architectural decision-makingsecuritySecurity-related fix, hardening, audit, or vulnerability remediation

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions