Auth engine

From qauth-labs/qauth · View interactive version

Auth engine is an AI agent skill from the GitHub repository qauth-labs/qauth. Auth engine rules for QAuth. Use when working with CredentialProvider implementations, token claim generation, the provider registry, or the federation layer. Enforces the pluggable provider pattern and correct token claim behaviour.

How to use this skill

Skill file

Auth Engine Rules

You are working in the QAuth authentication core.

CredentialProvider Pattern

Every authentication method implements the CredentialProvider interface:

// libs/sdk/plugin-sdk/src/lib/credential-provider.ts (re-exported by
// libs/server/federation/src/providers/credential-provider.interface.ts)
export interface CredentialProvider {
  readonly type: string;
  verify(input: unknown): Promise<VerifiedIdentity>;
  extractAttributes(result: VerifiedIdentity): UserAttribute[];
}

The auth engine:

  1. Looks up the credential from user_credentials by (realm_id, provider_type, external_sub)
  2. Passes credential data to provider.verify()
  3. Receives VerifiedIdentity
  4. Upserts user_attributes from provider.extractAttributes()
  5. Issues tokens with sub = users.id

The engine does not contain provider-specific logic. Switch/case on provider_type

belongs only in the provider registry, not in service routes.

Current Providers

fail-closed property, not a stage in an implementation — a stub resolving a

placeholder VerifiedIdentity would be an authentication-bypass primitive. Never

"finish" it, and never wire it into a login path. See AGENTS.md.

(default off). It does not go through this provider: it runs on the dedicated

/ui/wallet-login + /oid4vp/response seam

(apps/auth-server/src/app/routes/ui/wallet-login.ts,

apps/auth-server/src/app/routes/oid4vp/response.ts), validated end-to-end against a

mock wallet on the oid4vp-1.0-base profile.

real work.

Token Claims

OMIT entirely if no verified email — do not set null. Released in ID tokens, access tokens

and userinfo only under the email scope (resolveEmailClaimsForScopes)

Omit for password credentials (assuranceLevel: 'low' → no acr claim)

Claim Resolution

// Claim resolution order by source trust level
// wallet > oidc_* > self_reported
const emailAttr = await fastify.repositories.userAttributes.findVerifiedByUserIdAndKey(
  userId,
  'email'
);
// Returns undefined if no verified email → omit claim from token

Crypto

All signing, hashing, and key operations go through libs/server/jwt/ and libs/server/password/.

Never implement crypto directly in TypeScript service code.

The libs/server/password/ library wraps Argon2id for password hashing — use it via

the passwordHasher Fastify decorator. Do not call Argon2 directly.

Phase Status

Status below was checked against origin/main on 2026-08-31. Re-derive it from the

tree rather than trusting this list — a stale "we don't do X" misdirects every agent that

loads this skill (ADR-007:319-327).

WALLET_FEDERATION_ENABLED (default off), covering the OID4VP verifier, SD-JWT VC

validation, key attestations, status-list revocation, the claims pipeline and the browser

flow, with an E2E suite over account linking, returning login, the refusal to create an

account at wallet sign-in (ADR-009 §1, amended 2026-10-19) and acr. Validated only on

the oid4vp-1.0-base profile against a mock wallet; the

haip-1.0 profile and real-wallet interop are still open (#377, #376). The mechanism is

OID4VP 1.0, not SIOPv2 — HAIP 1.0 §5 mandates response_type=vp_token,

which excludes the Self-Issued ID Token. Do not implement SIOPv2. See

ADR-004 § Spec status (2026-07-20);

profile order is decided (#296 locked): oid4vp-1.0-base first, haip-1.0 second.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.