Authorization.ts overview
WorkOS roles in the core’s authorization kernel. A session’s workos.role and workos.roles (from its verified access token) become Role:: parents of the signed-in User::, so Auth.Rbac.policies written for those role slugs decide as they do over the core’s own role tables. Organizations are read-only here: membership and roles are managed in WorkOS.
Since v0.1.0
Exports Grouped by Category
layers
entityResolverLayer
An EntityResolver that gives the current session’s user its WorkOS roles as parents. It reads CurrentSession when it resolves, so it knows only the caller: any other User:: it is asked for is unknown (no roles). Role entities carry their roleHierarchy parents.
Signature
declare const entityResolverLayer: (options?: EntityResolverOptions) => Layer.Layer<Auth.Authorizer.EntityResolver>
Since v0.1.0
models
EntityResolverOptions (interface)
Options for entityResolverLayer.
Signature
export interface EntityResolverOptions {
/** Role inheritance, as `Auth.Rbac`'s `roleHierarchy`: `{ admin: ["member"] }`. */
readonly roleHierarchy?: Readonly<Record<string, ReadonlyArray<string>>>
/** The principal type the session's user is, `User` by default (`Auth.Rbac.DefaultPrincipalType`). */
readonly principalType?: string
}
Since v0.1.0
utils
sessionRoles
The role slugs a session carries, workos.role first, without duplicates.
Signature
declare const sessionRoles: (session: Auth.Types.Session) => ReadonlyArray<string>
Since v0.1.0