d4e254b3494de7ce47477b9421e8c8d3e035e104
2
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
605066d835 |
fix(identity): derive the caller the way the provider issues tokens
Infra decoded real tokens from both clients, and two of the three facts changed this code. A machine token carries NO sub at all: it names its caller by client_id, and the identity is that client. A person's token carries sub, the provider's stable identifier for the person. The subject is now derived explicitly -- sub when present, else client_id -- and a verified token asserting neither is refused rather than accepted as an anonymous caller, because accepting it would let any token the provider ever signed act as whoever the binding happened to hold. A machine identity is therefore per client registration, one identity per client, which is what makes per-agent identity a configuration decision rather than a code change. Scopes are read from either claim shape. The standard is a space-delimited scope string and this provider also emits an scp array; reading only one shape yields no scopes at all, which is worse than reading none deliberately. The audience-at-authorisation-endpoint trap is pinned by a test: a token minted without the requested audience arrives with aud empty, and the audience check refuses it. That refusal is correct and the fix is the request the human flow builds, not a weaker check here -- a test now fails if anyone weakens it. The PRD records both as constraints: a person's client and an agent's client are registered separately because a shared registration collapses the distinction the attribution rests on, and a person's token requests the audience at the authorisation endpoint as well as the token endpoint. Verified: task check exit 0; internal/infrastructure/oidc passes, including subject derivation for both token shapes and every refusal. |
||
|
|
2cc605ae09 |
feat(identity): verify provider tokens and attribute task actions to their actor
Two halves of one boundary: a credential resolves to an identity, and an action records which identity acted and whose authority it used. resource server. internal/infrastructure/oidc verifies a provider-issued bearer token against the provider's published keys, using an OSS OIDC library: archie compares no signature, validates no claim and rotates no key itself, holds no client secret and issues no session, so a compromised archie cannot mint an identity. Audience is required rather than optional -- a token minted for another service must not authenticate here -- and discovery happens at construction, so an unreachable provider is a startup failure rather than a request-time surprise. identity.Authenticate is the single place a credential becomes an identity, and it refuses in four distinguishable ways: no credential presented, a credential that did not verify (wrong key, expired, wrong issuer, wrong audience, malformed), a verified subject with no identity bound to it, and an identity that may not act. The order is deliberate: verification happens before any field of the token is used, so nothing an unverified token carries can select an identity. A suspended identity is refused even though its credential verified, because suspension is archie's decision and must not depend on the provider withdrawing a token. The binding is the second bridge beside the legacy-name alias: identity_subjects keys (issuer, subject) so the same subject string from another issuer is a different caller, and rebinding moves a subject so two identities can never claim one provider subject. The contract Authenticate needs is SubjectResolver, narrower than Repository, so a consumer that only authenticates does not take the whole identity CRUD surface -- and staterpc.Client, which asserts Repository, does not need a new RPC to satisfy it. attribution. taskactions now records two identities per action: the acting identity and the authorising principal, both on the event row as new columns added through the existing migration table. The rule that the bug turned on is enforced by the event kind describing the actor: a person's approval is human_approved, an agent's is agent_approved, and an action with no verified actor is task_approved, a task-level event that credits nobody. An agent acting under a person's standing approval records itself as the actor and that person as the principal, so "approved by came from me" is answerable from the record rather than asserted. Scope and actor are separated: scope decides which task a caller may touch and is never promoted into an actor, because the dashboard's credential is a shared token and possession of it is not evidence that a person was at the keyboard. That last point is a deliberate fidelity trade, and the reason the transport is not wired: the dashboard action path passes no actor yet, so dashboard approvals are now recorded as task_approved rather than claimed as a human's. Recording nothing false is the requirement; naming the human verifiably needs the dashboard to authenticate a token and resolve it, which needs two new state-store RPCs (ResolveIdentitySubject, BindIdentitySubject) -- the next piece, not a rewrite: the verifier is a one-method interface, so introspection would be a second implementation of it. Verified: task check exit 0; focused runs recorded in the handoff. Opaque authelia_at_ tokens were inspected rather than assumed and cannot be verified against public keys; infra is configuring access_token_signed_response_alg RS256 on the archie client, with audience https://archie.catlow.cloud and issuer https://auth.catlow.cloud. |