type

AccessContext

Actor, target, locale, data, and nested API supplied to an access rule.

Source ridu.go:16

Contextcontext.Context
Request cancellation and deadline context.
OperationOperation
The operation being authorized.
CollectionIDschema.StableID
Target collection identity.
GlobalIDschema.StableID
Target global identity, when applicable.
IDstring
Current document ID; empty for create and list.
Actor*store.Document
Authenticated actor, or nil.
ActorCollectionschema.CollectionSlug
The exact auth collection that owns Actor.
Datastore.Values
Detached incoming values for writes.
Local*LocalAPI
Nested operations in the active transaction.
Localeschema.LocaleCode
Selected locale.
AllLocalesbool
Whether every locale is selected.

Use the root alias in application configuration.

Example

go
func ownerOnly(ctx ridu.AccessContext) (ridu.AccessDecision, error) {
  if ctx.Actor == nil {
    return ridu.Deny(), nil
  }
  author, err := query.NewPath("author")
  if err != nil {
    return ridu.Deny(), err
  }
  return ridu.Where(
    query.Equal(author, query.String(ctx.Actor.ID)),
  ), nil
}