Adds an attribute-based access control layer to Payload. Attribute providers such as tenant, role or custom ones like region are compiled into Payload where clauses and reuse data enriched in the user JWT. Collections opt in through a custom abac config. Requires Payload 3 or later.
Installation
npm i @shefing/abac183
Stars
8
Forks
89
Open Issues
3 months ago
Last Updated
8
Weekly Downloads
v0.0.4
npm Version
122.6 KB
Unpacked Size
0
Dependencies
183+4 since Sep 7
| Date | Stars |
|---|---|
| Dec 6, 2026 | 183 |
| Dec 5, 2026 | 183 |
| Dec 4, 2026 | 183 |
| Dec 3, 2026 | 183 |
| Dec 2, 2026 | 183 |
| Dec 1, 2026 | 183 |
| Nov 30, 2026 | 183 |
| Nov 29, 2026 | 183 |
| Nov 28, 2026 | 183 |
| Nov 27, 2026 | 183 |
| Nov 26, 2026 | 183 |
| Nov 25, 2026 | 182 |
| Nov 24, 2026 | 182 |
| Nov 23, 2026 | 182 |
| Nov 22, 2026 | 182 |
| Nov 21, 2026 | 182 |
| Nov 20, 2026 | 182 |
| Nov 19, 2026 | 182 |
| Nov 18, 2026 | 182 |
| Nov 17, 2026 | 182 |
| Nov 16, 2026 | 183 |
| Nov 15, 2026 | 183 |
| Nov 14, 2026 | 183 |
| Nov 13, 2026 | 183 |
| Nov 12, 2026 | 183 |
| Nov 11, 2026 | 183 |
| Nov 10, 2026 | 183 |
| Nov 9, 2026 | 182 |
| Nov 8, 2026 | 182 |
| Nov 7, 2026 | 182 |
| Nov 6, 2026 | 182 |
| Nov 5, 2026 | 182 |
| Nov 4, 2026 | 182 |
| Nov 3, 2026 | 181 |
| Nov 2, 2026 | 181 |
| Nov 1, 2026 | 181 |
| Oct 31, 2026 | 181 |
| Oct 30, 2026 | 181 |
| Oct 29, 2026 | 181 |
| Oct 28, 2026 | 181 |
| Oct 27, 2026 | 181 |
| Oct 26, 2026 | 181 |
| Oct 25, 2026 | 181 |
| Oct 24, 2026 | 181 |
| Oct 23, 2026 | 181 |
| Oct 22, 2026 | 181 |
| Oct 21, 2026 | 180 |
| Oct 20, 2026 | 180 |
| Oct 19, 2026 | 180 |
| Oct 18, 2026 | 180 |
| Oct 17, 2026 | 180 |
| Oct 16, 2026 | 180 |
| Oct 15, 2026 | 180 |
| Oct 14, 2026 | 180 |
| Oct 13, 2026 | 180 |
| Oct 12, 2026 | 180 |
| Oct 11, 2026 | 180 |
| Oct 10, 2026 | 180 |
| Oct 9, 2026 | 180 |
| Oct 8, 2026 | 180 |
| Oct 7, 2026 | 180 |
| Oct 6, 2026 | 180 |
| Oct 5, 2026 | 180 |
| Oct 4, 2026 | 180 |
| Oct 3, 2026 | 180 |
| Oct 2, 2026 | 180 |
| Oct 1, 2026 | 180 |
| Sep 30, 2026 | 180 |
| Sep 29, 2026 | 180 |
| Sep 28, 2026 | 180 |
| Sep 27, 2026 | 180 |
| Sep 26, 2026 | 180 |
| Sep 25, 2026 | 180 |
| Sep 24, 2026 | 179 |
| Sep 23, 2026 | 179 |
| Sep 22, 2026 | 179 |
| Sep 21, 2026 | 179 |
| Sep 20, 2026 | 179 |
| Sep 19, 2026 | 179 |
| Sep 18, 2026 | 179 |
| Sep 17, 2026 | 179 |
| Sep 16, 2026 | 179 |
| Sep 15, 2026 | 179 |
| Sep 14, 2026 | 179 |
| Sep 13, 2026 | 179 |
| Sep 12, 2026 | 179 |
| Sep 11, 2026 | 179 |
| Sep 10, 2026 | 179 |
| Sep 9, 2026 | 179 |
| Sep 8, 2026 | 179 |
| Sep 7, 2026 | 179 |
Shared by 4 plugins in shefing/payload-tools.
90 since Sep 7
| Date | Weekly downloads |
|---|---|
| Dec 6, 2026 | 9 |
| Dec 5, 2026 | 6 |
| Dec 4, 2026 | 7 |
| Dec 3, 2026 | 7 |
| Dec 2, 2026 | 3 |
| Dec 1, 2026 | 7 |
| Nov 30, 2026 | 7 |
| Nov 29, 2026 | 6 |
| Nov 28, 2026 | 5 |
| Nov 27, 2026 | 4 |
| Nov 26, 2026 | 4 |
| Nov 25, 2026 | 5 |
| Nov 24, 2026 | 1 |
| Nov 23, 2026 | 1 |
| Nov 22, 2026 | 3 |
| Nov 21, 2026 | 4 |
| Nov 20, 2026 | 4 |
| Nov 19, 2026 | 4 |
| Nov 18, 2026 | 3 |
| Nov 17, 2026 | 4 |
| Nov 16, 2026 | 4 |
| Nov 15, 2026 | 3 |
| Nov 14, 2026 | 2 |
| Nov 13, 2026 | 2 |
| Nov 12, 2026 | 2 |
| Nov 11, 2026 | 2 |
| Nov 10, 2026 | 2 |
| Nov 9, 2026 | 4 |
| Nov 8, 2026 | 5 |
| Nov 7, 2026 | 5 |
| Nov 6, 2026 | 5 |
| Nov 5, 2026 | 5 |
| Nov 4, 2026 | 5 |
| Nov 3, 2026 | 4 |
| Nov 2, 2026 | 2 |
| Nov 1, 2026 | 0 |
| Oct 31, 2026 | 0 |
| Oct 30, 2026 | 0 |
| Oct 29, 2026 | 0 |
| Oct 28, 2026 | 0 |
| Oct 27, 2026 | 2 |
| Oct 26, 2026 | 3 |
| Oct 25, 2026 | 4 |
| Oct 24, 2026 | 5 |
| Oct 23, 2026 | 5 |
| Oct 22, 2026 | 8 |
| Oct 21, 2026 | 10 |
| Oct 20, 2026 | 9 |
| Oct 19, 2026 | 8 |
| Oct 18, 2026 | 7 |
| Oct 17, 2026 | 7 |
| Oct 16, 2026 | 8 |
| Oct 15, 2026 | 12 |
| Oct 14, 2026 | 10 |
| Oct 13, 2026 | 9 |
| Oct 12, 2026 | 9 |
| Oct 11, 2026 | 10 |
| Oct 10, 2026 | 9 |
| Oct 9, 2026 | 8 |
| Oct 8, 2026 | 1 |
| Oct 7, 2026 | 1 |
| Oct 6, 2026 | 1 |
| Oct 5, 2026 | 1 |
| Oct 4, 2026 | 0 |
| Oct 3, 2026 | 1 |
| Oct 2, 2026 | 1 |
| Oct 1, 2026 | 1 |
| Sep 30, 2026 | 1 |
| Sep 29, 2026 | 1 |
| Sep 28, 2026 | 1 |
| Sep 27, 2026 | 1 |
| Sep 26, 2026 | 3 |
| Sep 25, 2026 | 3 |
| Sep 24, 2026 | 3 |
| Sep 23, 2026 | 3 |
| Sep 22, 2026 | 3 |
| Sep 21, 2026 | 5 |
| Sep 20, 2026 | 5 |
| Sep 19, 2026 | 4 |
| Sep 18, 2026 | 5 |
| Sep 17, 2026 | 5 |
| Sep 16, 2026 | 5 |
| Sep 15, 2026 | 6 |
| Sep 14, 2026 | 4 |
| Sep 13, 2026 | 7 |
| Sep 12, 2026 | 6 |
| Sep 11, 2026 | 5 |
| Sep 10, 2026 | 7 |
| Sep 9, 2026 | 8 |
| Sep 8, 2026 | 9 |
| Sep 7, 2026 | 9 |
Each point is npm's rolling 7-day download count.
Health Score
Composite score based on GitHub activity, stars, npm downloads, publish recency, dependency count, and package size.
Badge for your README
[](https://payloaddirectory.dev/plugins/888484677-abac)<a href="https://payloaddirectory.dev/plugins/888484677-abac"><img src="https://payloaddirectory.dev/badge/888484677-abac.svg" alt="Payload Directory"></a>README
@shefing/abac adds a pluggable, Payload-native attribute-based access control layer.
where clauses whenever possible.pnpm add @shefing/abac
import type { AttributeProvider } from '@shefing/abac'
const tenantAttribute: AttributeProvider<string | null> = {
key: 'tenant',
fromUser: (user) => (typeof user.tenant === 'string' ? user.tenant : null),
match: (userValue, docValue) => userValue != null && userValue === docValue,
toWhere: (userValue) => ({ tenant: { equals: userValue } }),
enrichJWT: (user) => ({ tenant: user.tenant ?? null }),
}
import { abacPlugin } from '@shefing/abac'
plugins: [
abacPlugin({
attributes: [
{
key: 'tenant',
fromUser: (user) => user.tenant,
match: (userValue, docValue) => userValue === docValue,
toWhere: (userValue) => ({ tenant: { equals: userValue } }),
enrichJWT: (user) => ({ tenant: user.tenant }),
},
],
}),
]
Then opt collections in with custom.abac:
custom: {
abac: {
tenant: {
docField: 'tenant',
},
},
}
geo is intentionally documented as an example for v1 rather than shipped as a built-in:
const geoAttribute = {
key: 'geo',
fromUser: (user) => user.region,
match: (userRegion, docRegion) => userRegion === docRegion,
toWhere: (userRegion) => ({ region: { equals: userRegion } }),
}
Current limitation (v1): each attribute provider resolves to a single value per user (e.g.
user.tenant = 'tenant-a'). If a user belongs to multiple tenants the engine only sees the first one.
The v0.2 milestone will extend the engine and tenantAttribute to handle array-valued attributes natively:
// user.tenants = ['tenant-a', 'tenant-b'] ← multiple memberships
const multiTenantAttribute = {
key: 'tenant',
fromUser: (user) => Array.isArray(user.tenants) ? user.tenants : [],
match: (userTenants, docTenant) =>
Array.isArray(userTenants) && userTenants.includes(docTenant as string),
// toWhere will emit { tenant: { in: ['tenant-a', 'tenant-b'] } }
toWhere: (userTenants) => ({ tenant: { in: userTenants as string[] } }),
enrichJWT: (user) => ({ tenants: Array.isArray(user.tenants) ? user.tenants : [] }),
}
This closes the main gap vs. Payload's official plugin-multi-tenant, which stores a tenants[] array per user. The same pattern applies to any set-valued attribute (multi-region, multi-clearance, etc.).
AND.tenantAttribute() and roleAttribute() are exported from the package entry.roleAttribute() is additive with @shefing/authorization: it preserves JWT role context and can short-circuit admins, but it does not replace RBAC collection permissions.test-app/tests/e2e-plugins/abac.spec.ts once the feature is fully wired.| Version | Item | Status |
|---|---|---|
| v1 | Single-value attribute providers (tenant, role, custom) | ✅ Shipped |
| v1 | JWT enrichment — zero extra DB queries per request | ✅ Shipped |
| v1 | GET /api/me/permissions endpoint | ✅ Shipped |
| v1 | abacFilterOptions relationship field helper | ✅ Shipped |
| v1 | Fail-closed safety + startup config validation | ✅ Shipped |
| v0.2 | Multi-value attribute support (tenants[], { in: [...] } WHERE, array match) | ✅ Shipped |
| v0.2 | readVersions / unlock action guards | ✅ Shipped |
| v0.2 | pluginContext singleton → factory (test isolation) | ✅ Shipped |
| v0.3 | Optional admin UI: tenant switcher component | 💡 Planned |
| v0.3 | isGlobal collection mode (per-tenant globals) | 💡 Planned |
| v0.3 | Per-tenant roles (tenantRoleAttribute) | 💡 Planned |
| v0.3 | i18n support | 💡 Planned |
Topics
multi tenant
Manage multiple tenants and tenant-scoped content from a single Payload admin panel
100165.4k/wk46.1kv3 v4
payload plugin sharing
Share records with users and organizations through groups with Owner, Manager and Viewer levels
76425/wk0v3
payload plugin roles
Per-site role ladders and access helpers for multi-tenant Payload sites
76128/wk0v3
payload gatekeeper
Role-based access control for Payload v3 with wildcard permissions, auto role assignment and a managed Roles collection
39199/wk25v3
payload plugin positions
Scoped, dated position grants for users on a site, organization or project, with host-defined types and an audit trail
76382/wk0v3
payload plugin guardians
Link minors to guardians, turn guardian edits into suggestions the minor decides, and route requests for approval
76366/wk0v3