Documentation
¶
Overview ¶
Package gate builds ContentKit's route gates from the host's auth. It asks the auth.Authenticator who a request is, at most once, builds the access.Actor from the Verified, enforces the route's tier (httpapi.Tier) and answers every refusal with the status and challenge authkit/auth's Refuse gives, in ContentKit's error body.
Index ¶
- Constants
- func Actor(ctx context.Context) access.Actor
- func AsHost(ctx context.Context) context.Context
- func Can(ctx context.Context, a auth.Authenticator, actor access.Actor, perm string) (bool, error)
- func Check(a auth.Authenticator, perms ...access.Permission) error
- func GroupEditor(ctx context.Context, a auth.Authenticator, actor access.Actor, ...) (bool, error)
- func Host() access.Actor
- func RootScope(ctx context.Context, a auth.Authenticator) (s auth.Scope, err error)
- func Site(ctx context.Context) string
- type Gate
Constants ¶
const HostSubject = "contentkit"
HostSubject is the actor id of the engine's own in-process client.
Variables ¶
This section is empty.
Functions ¶
func AsHost ¶ added in v0.83.0
AsHost marks ctx as a request of the engine's in-process client: the gate admits it as the host application holding every permission, with no credential. Only in-process code can set it; nothing on the wire does.
func Can ¶
Can reports whether actor holds perm, an access.Permission's name, as staff: the root:<resource>:<action> permission in the Authenticator's root scope. It is the one place a staff permission is checked; a tenant that corresponded to a group would also admit that group's merchant: form here. An error never grants.
func Check ¶
func Check(a auth.Authenticator, perms ...access.Permission) error
Check refuses a missing Authenticator, typed nil pointers included. A module with staff routes passes their permissions: the Authenticator must name its root scope (auth.Root), where they are held, and know each one when it can say (auth.PermissionCatalog), so a host whose roles lack one fails at start instead of refusing every request.
func GroupEditor ¶ added in v0.83.0
func GroupEditor(ctx context.Context, a auth.Authenticator, actor access.Actor, owner, scope string, perms ...string) (bool, error)
GroupEditor reports whether actor edits a user-owned group, by its owner and AuthKit scope (groups' owner_user_id and auth_scope): its owner, or a holder of any of perms in the scope, under the authority of a's root scope. Staff are the caller's to admit. An error never grants.
func Host ¶ added in v0.83.0
Host is the engine's own actor, holding every permission: what its in-process client acts as, and its own cascades.