type
AccessContext
Identity, operation, locale, and request data for an access rule.
Example
func ownerOnly(ctx ridu.AccessContext) (ridu.AccessDecision, error) {
if ctx.Actor == nil {
return ridu.Deny(), nil
}
return ridu.Where(query.Equal("author", ctx.Actor.ID)), nil
}Properties
| Property | Type | Description |
|---|---|---|
Context | context.Context | Request cancellation and deadline context. |
Operation | operation.Kind | The operation being authorized. |
CollectionID | schema.StableID | Target collection identity. |
GlobalID | schema.StableID | Target global identity, when applicable. |
ID | string | Current document ID; empty for create and list. |
Actor | *store.Document | Authenticated actor, or nil. |
ActorCollection | schema.CollectionSlug | The exact auth collection that owns Actor. |
Data | store.Values | Detached incoming values for writes. |
Local | *LocalAPI | Nested operations in the active transaction. |
Locale | schema.LocaleCode | Selected locale. |
AllLocales | bool | Whether every locale is selected. |
Full signature
type AccessContext struct {
// Context is the request-scoped cancellation and deadline context.
Context context.Context
// Operation is the collection operation being evaluated.
Operation operation.Kind
// CollectionID is the stable identity of the target collection.
CollectionID schema.StableID
// GlobalID is the stable identity of the target global, when applicable.
GlobalID schema.StableID
// ID is the requested document ID. It is empty for creates and list reads.
ID string
// Actor is the authenticated document, or nil for an anonymous request.
Actor *store.Document
// ActorCollection identifies the exact auth collection that owns Actor.
ActorCollection schema.CollectionSlug
// Data is a detached snapshot of incoming create or update values.
Data store.Values
// Local exposes nested operations through the same transaction and access
// pipeline. Rules must avoid recursively invoking themselves without a guard.
Local *LocalAPI
// Locale is the exact content locale currently being authorized.
Locale schema.LocaleCode
// AllLocales reports that the caller requested every locale. Such a request
// may evaluate the rule once for each configured Locale and requires
// compatible decisions across them.
AllLocales bool
}