type

AccessContext

Identity, operation, locale, and request data for an access rule.

Example

go
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

PropertyTypeDescription
Contextcontext.ContextRequest cancellation and deadline context.
Operationoperation.KindThe operation being authorized.
CollectionIDschema.StableIDTarget collection identity.
GlobalIDschema.StableIDTarget global identity, when applicable.
IDstringCurrent document ID; empty for create and list.
Actor*store.DocumentAuthenticated actor, or nil.
ActorCollectionschema.CollectionSlugThe exact auth collection that owns Actor.
Datastore.ValuesDetached incoming values for writes.
Local*LocalAPINested operations in the active transaction.
Localeschema.LocaleCodeSelected locale.
AllLocalesboolWhether 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 }

Source core/access.go:16