Module Algostream_infrastructure_auth.Principal

Who is making a request.

Deliberately lives here rather than in the network library: the dependency runs network -> auth and never back. Nothing in this library knows that HTTP exists — it takes strings and returns results — which is what makes it testable without a socket.

type t =
  1. | Anonymous
    (*

    No credential was presented. Reaches a handler only on a route declared Scope.t.Public.

    *)
  2. | Key of {
    1. kid : string;
      (*

      public key id — safe to log and to write into an audit record

      *)
    2. label : string;
      (*

      the operator's own description, as the keystore read at that moment

      *)
    3. scopes : Scope.Set.t;
    }
val kid : t -> string

The key id, or "-" for Anonymous. Never None, because every audit record needs an actor column and a missing value there should read as "nobody" rather than as an absent field.

val label : t -> string
val scopes : t -> Scope.Set.t
val has : t -> Scope.t -> bool

has t scope is Scope.satisfies against this principal's grants.

val to_assoc : t -> (string * string) list

Flat fields for /api/whoami and for audit records. Contains no secret — by construction, since a principal never carries one.

val to_string : t -> string