type
AccessContext
type AccessContext struct {
// Context is the request-scoped cancellation and deadline context.
Context context.Context
// Operation is the collection operation being evaluated.
Operation Operation
// 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 schema.LocaleCode
AllLocales bool
}Identity, operation, locale, and request data for an access rule.
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.
Example
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
}