Auth / Auth and Guard

Auth and Guard

When users sign in with a session cookie, your server has two distinct security questions on every request: who is asking, and what are they allowed to read or change. Mixing those checks inside ad-hoc handlers either locks out public visitors or leaves authorization gaps across server queries, sync journals, and AI agents.

foldkit-auth answers who is asking by turning a request's session into your application's principal (User, or Option.none() for an unauthenticated visitor). foldkit-guard answers what they may do by enforcing read, write, and capability rules against that principal across every seam. Both packages work independently or together through that single principal value.