Use this file to discover all available pages before exploring further.
PocketBase uses rule-based access control to determine who can access and modify your data. Rules are written as filter expressions and applied at the collection level.
The authRule is special because it applies after successful authentication:
type collectionAuthOptions struct { // AuthRule could be used to specify additional record constraints // applied after record authentication and right before returning the // auth token response to the client. // // For example, to allow only verified users you could set it to // "verified = true". // // Set it to empty string to allow any Auth collection record to authenticate. // // Set it to nil to disallow authentication altogether for the collection // (that includes password, OAuth2, etc.). AuthRule *string `json:"authRule"`}
The manageRule gives admin-like permissions for auth records:
type collectionAuthOptions struct { // ManageRule gives admin-like permissions to allow fully managing // the auth record(s), eg. changing the password without requiring // to enter the old one, directly updating the verified state and email, etc. // // This rule is executed in addition to the Create and Update API rules. ManageRule *string `json:"manageRule"`}
What manage rule allows:
Change passwords without requiring the old password
Directly update the verified state
Modify email without confirmation
Ignore email visibility settings when viewing records
Example configurations:
// Allow superusers only (default secure setting)collection.ManageRule = nil// Allow the user to manage their own recordcollection.ManageRule = types.Pointer("@request.auth.id = id")// Allow admin users to manage any recordcollection.ManageRule = types.Pointer("@request.auth.role = 'admin'")// Allow users to manage records in their organizationcollection.ManageRule = types.Pointer("@request.auth.organizationId = organizationId")
The manage rule enables email visibility for matched records:
// From apis/record_helpers.go:462if collection.ManageRule == nil || *collection.ManageRule == "" { return nil // no manage rule to check}// Fetch the ids of the managed recordsresolver := core.NewRecordFieldResolver(app, collection, requestInfo, true)expr, err := search.FilterData(*collection.ManageRule).BuildExpr(resolver)// Ignore the email visibility check for the managed recordsfor _, id := range managedIds { if rec, ok := mappedRecords[id]; ok { rec.IgnoreEmailVisibility(true) }}
The manage rule is executed in addition to the Create and Update API rules. Use it carefully as it grants elevated permissions.
List Rule: Acts as a filter on the query results. Records not matching the rule are excluded from the list.
View Rule: Acts as a permission check. If the rule doesn’t match, the request is denied with a 403/404 error.
// List rule examplecollection.ListRule = types.Pointer("status = 'published'")// Result: Only published records are returned in list queries// View rule example collection.ViewRule = types.Pointer("@request.auth.id = userId")// Result: Returns 404 if user tries to view someone else's record
The List rule is applied as a query filter, while the View rule is a binary permission check.