Generated apps turn SLang security declarations into runtime authentication and authorization behavior.Documentation Index
Fetch the complete documentation index at: https://docs.withsutro.com/llms.txt
Use this file to discover all available pages before exploring further.
Request Flow
When a request reaches a generated app:- The runtime extracts credentials from the request.
- It validates the credentials and establishes a subject.
- It resolves principals, roles, groups, and permissions for that subject.
- It exposes the result to SLang as
@subject. - It evaluates the trigger
authblock before running the action.
401. If the subject is authenticated but does not satisfy the auth rule, the request fails with 403.
Subject Resolution
The generated app can resolve@subject.entity only when the token subject matches a SLang entity marked with subject and identity.
identity email declaration tells the generated app which user field is used for registration and login. The runtime also tracks the internal @id, which lets @subject.entity fetch the persisted user row.
Principals, Roles, and Permissions
Principals are security facts about a subject. Roles and permissions are derived from the model relationships declared in SLang:group @idmarks an entity whose instances can scope permissions.role roleFieldmarks the enum field that carries a role.permissions Subject->relationPath->roleValuegrants permission strings to that role.
@subject.roles and principal permissions. Trigger auth checks such as @subject can "project:read" in Organization(@request.path.organizationId) are evaluated from that runtime subject context.
Generated Auth Endpoints
Subject declarations enable generated auth endpoints:POST /registerPOST /loginPOST /refreshGET /.well-known/jwks.json
identity email, clients send the user’s email as the identity value.
Practical Guidance
Keep auth checks at the trigger boundary for coarse access control, and keep ownership checks inside actions for record-level safety. For example, a trigger can require@subject is @defined, while the action uses single Document where @id == documentId and owner == @subject.entity.