Repository navigation
Description
Reconciliation — 2026-10-05
- The existing Oxy API lane uses canonical credential/workload-derived minting and strict lifetime/receiver checks: canonical mint; workload authority; receiver negative controls.
- Published shared SDK receiver adoption and bounded live revocation were accepted under [Arquitectura Oxy] Consolidar identidad autorización MCP y acceso comercial #1519: I04/I11 accepted publication, consumer and runtime evidence.
This is completion of reusable Oxy-audience foundations, not acceptance of resource-targeted Mercaria→Moovo minting. The requested resource API/grant intersection, per-resource cache isolation and generic audience migration below remain open. No checkbox for that different flow is inferred from aud: oxy-api.
Status 2026-09-30 (audited against main f345d27)
Still to do:serviceTokenMint.service.ts:54hardcodesaud: 'oxy-api'for BOTH the key/secret mint and the workload mint (/auth/service-token/workload, ADR 0026) — cover both. Payments carve-out still atroutes/auth.ts:3682. No compatibility route foroxy-apitokens: clean cut.
Part of #873. Depends on #874 and #875.
Goal
Extend Oxy service-token issuance so a service credential can request a short-lived token for one registered resource application and a bounded service-scope subset. The mint must derive every identity and permission from Oxy records and must not trust caller-supplied application ids as authority.
Token request
Evolve the existing service-token flow according to #874, using standard OAuth parameters where practical. The request must identify:
- Existing service credential client id and secret.
- Target resource application or audience.
- Requested service scopes.
- No caller application id; it is resolved from the credential.
- No user id unless a separate explicit delegation flow is being used.
Preserve a compatibility route or versioned migration for current oxy-api service tokens without making an unscoped token valid against every application resource.
Authorization sequence
- Resolve the usable
ApplicationCredentialby client id. - Verify the secret with the existing constant-time/hash path.
- Resolve the owning caller
Applicationand require active status. - Resolve the requested resource
Applicationand require active status. - Require environment compatibility.
- Resolve the active application service grant from Model resource service APIs and application-to-application grants #875.
- Intersect requested scopes with the resource API definition, grant and credential binding.
- Reject unknown, retired, ungranted or cross-environment scopes.
- Mint a short-lived token with the exact caller, credential, resource, environment and effective scopes.
- Stamp safe last-used and audit information without logging secrets or raw tokens.
Token contract
Implement the claim shape selected by #874, including:
type: service.- Caller
appId. credentialId.- Resource application audience.
- Environment.
- Effective service scopes.
iss,iat,expand key id as applicable.- A token/version marker if required for safe migration.
Do not use application display name, domain or official badge as authority.
Cache and revocation behavior
- Cache keys include credential, audience, environment and normalized scope set.
- A token for Moovo cannot be returned for Oxy API or another application.
- Credential rotation does not mix token caches.
- Grant revocation prevents minting a replacement token immediately.
- Already issued token behavior follows ADR: define canonical application principals, resource audiences and service grants #874's bounded lifetime/revocation decision.
- Resource or caller suspension prevents minting.
- Scope reductions cannot be widened by an empty requested scope fallback.
- Concurrent equivalent requests may converge safely without sharing tokens across credential tuples.
Error contract
Use safe OAuth-style errors or the accepted service-token contract for:
- Invalid client.
- Invalid resource.
- Invalid or unavailable scope.
- Environment mismatch.
- Missing/revoked/suspended grant.
- Suspended application.
- Revoked or expired credential.
- Unsupported compatibility request.
Do not reveal whether an unrelated application has a private grant.
Tests
Use real persistence and cover:
- Mercaria production credential to Moovo production.
- Wrong resource.
- No grant.
- Scope outside grant.
- Scope outside credential binding.
- Development credential to production resource.
- Grant revoked during token refresh.
- Credential rotation grace and final revocation.
- Resource suspended.
- Token cache isolation by audience and scopes.
- Current Oxy API compatibility path.
- Request body trying to spoof caller application id.
- Empty-scope and unknown-scope behavior.
- Audit and last-used fields.
Acceptance criteria
- Mercaria can mint a token whose audience is the existing Moovo application id.
- The token contains only the exact effective scopes permitted by Model resource service APIs and application-to-application grants #875.
- A token for one resource cannot be replayed as a token for another resource.
- Caller identity comes only from the resolved credential.
- Environment and lifecycle checks fail closed.
- Current service-token consumers have a tested migration path.
- No local or shared
SERVICE_SECRETis required by this flow. - Documentation and SDK contracts can rely on one authoritative token mint.
Activity