feat(credentials): add stage 3 authenticated OAuth and access-token issuance
Add explicit legacy/broker configuration. Broker mode requires a protected keyring, product-approved permission profiles and enabled platform OAuth; production requires PostgreSQL. Default legacy behavior stays unchanged. Wire the broker to v2 signed device status, authorization start/status and access-token issuance routes. Bind proofs to protocol, environment, app, method/path and complete payload; verify nonce, certificate, owner and binding generation. Add an additive generation migration and return the current generation in binding receipts or authenticated bootstrap status. Persist encrypted OAuth state and atomically claim callbacks. Verify the actual consenting user, supersede older pending authorization intents and recheck bindings/transactions before credential writes and issuance. Preserve rotated credentials if unbind occurs mid-refresh, but deny issuance. Return an explicit access-only response and record metadata-only audit. Extract shared legacy device authentication so notifications do not depend on the business proxy module. Broker mode omits legacy refresh/claim/start and /work/api routes; authorization cards reference server-owned v2 transactions. Document signatures, configuration and migration boundaries. Validation: 185 passed, 3 skipped (real PostgreSQL not configured), with 15 existing dependency deprecation warnings. New API coverage: 38 passed, 1 real PostgreSQL case skipped. AST, docs and staged diff checks pass. No production deployment, key generation, client upgrade or real Work API calls were performed. Compose/mount configuration, full unbind/connection compensation and durable message-task lifecycle remain later stages.
This commit is contained in:
@@ -65,7 +65,7 @@ class OAuth:
|
||||
await rate_limit(self.redis, "oauth:start:" + peer(request), 20)
|
||||
owner = ""
|
||||
if body.host_id:
|
||||
from .work_api import device_owner
|
||||
from .device_auth import device_owner
|
||||
owner = await device_owner(self.settings, self.redis, self.store, body.host_id,
|
||||
body.proof, "work-oauth-v1", {})
|
||||
async with self.lock:
|
||||
|
||||
Reference in New Issue
Block a user