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.
This commit is contained in:
19 files changed
+1146
-88
No files matched your search
@@ -39,6 +39,20 @@ const (
|
||||
// seeing, because it explains why a task changed course.
|
||||
KindHumanApproved = "human_approved"
|
||||
KindHumanRejected = "human_rejected"
|
||||
// KindAgentApproved and KindAgentRejected record that an agent performed
|
||||
// the action. They exist because the event kind describes the ACTOR: an
|
||||
// agent approving under a person's standing authority is not a human
|
||||
// approval, and recording it as one asserts something false. The authority
|
||||
// it acted under is PrincipalID, which is a separate fact.
|
||||
KindAgentApproved = "agent_approved"
|
||||
KindAgentRejected = "agent_rejected"
|
||||
// KindTaskApproved and KindTaskRejected record an approval or rejection that
|
||||
// archie cannot attribute to anyone: the request carried no identity archie
|
||||
// could verify. They are task-level events that claim nothing about the
|
||||
// actor, which is the honest record -- a human's approval and an agent's are
|
||||
// recorded as human_* and agent_* respectively.
|
||||
KindTaskApproved = "task_approved"
|
||||
KindTaskRejected = "task_rejected"
|
||||
// KindTaskRetried records what the retry was escaping from. RetryTask
|
||||
// clears stage and park_reason in the same statement that increments the
|
||||
// count, so this event is the only place that context survives.
|
||||
@@ -129,9 +143,24 @@ type Event struct {
|
||||
// as a first run. The tag is deliberately not omitempty so that
|
||||
// unattributed and absent stay distinguishable on the wire and in the
|
||||
// array the dashboard renders.
|
||||
Attempt int `json:"attempt"`
|
||||
Detail string `json:"detail,omitempty"`
|
||||
Data map[string]any `json:"data,omitempty"`
|
||||
Attempt int `json:"attempt"`
|
||||
// ActorID is the identity that performed the action this event records,
|
||||
// derived from the credential the request presented. Empty means the event
|
||||
// has no actor: the producers that are task-agnostic or pre-date this field
|
||||
// make no claim about who acted, and a reader must report that rather than
|
||||
// assume a human did.
|
||||
ActorID string `json:"actor_id,omitempty"`
|
||||
// ActorKind is the acting identity's kind, kept beside ActorID so a reader
|
||||
// can tell an agent's action from a person's without resolving the identity
|
||||
// -- and so an agent's action can never be displayed as a human's.
|
||||
ActorKind string `json:"actor_kind,omitempty"`
|
||||
// PrincipalID is the identity whose authority the action used, which is not
|
||||
// the acting identity when an agent acts under a person's standing approval
|
||||
// ("approved by came from me"). Empty means UNATTRIBUTED: no authority was
|
||||
// recorded, which is a different fact from the actor authorising itself.
|
||||
PrincipalID string `json:"principal_id,omitempty"`
|
||||
Detail string `json:"detail,omitempty"`
|
||||
Data map[string]any `json:"data,omitempty"`
|
||||
}
|
||||
|
||||
// Sub is one subscriber: a bounded channel plus a drop counter.
|
||||
|
||||
Reference in new issue
Block a user