Skip to main content

Permissions Reference

Unchained Engine uses a declarative, role-based access control (RBAC) system with 113 permission actions and context-aware evaluation.

Built-in Roles​

RoleScopeDescription
adminAll actionsFull access to everything
__loggedIn__Own dataAuthenticated users can manage their own data
__all__Public dataPublic read access to products, assortments, and localization
__notLoggedIn__No built-in rulesAuto-added for anonymous users; register/login is granted via __all__
__notAdmin__Auto-addedAdded to all non-admin authenticated users

Roles __all__, __loggedIn__, __notLoggedIn__, and __notAdmin__ are special roles automatically assigned during permission evaluation. You don't assign them to users manually.

Permission Actions​

View Permissions​

ActionDescription
viewProduct, viewProductsView products (public: active only)
viewOrder, viewOrdersView orders (loggedIn: own only)
viewUser, viewUsers, viewUserCountView user data
viewUserRoles, viewUserPublicInfos, viewUserPrivateInfosView user details
viewUserContactInfosView a user's primary e-mail and last checkout contact (primaryEmail, lastContact) without the other private data
viewUserOrders, viewUserQuotations, viewUserEnrollments, viewUserTokensView user relations
viewUserProductReviewsView user's reviews
viewAssortment, viewAssortmentsView assortments (public: active only)
viewFilter, viewFiltersView filters (public: active only)
viewLanguage, viewLanguagesView languages (public: active only)
viewCountry, viewCountriesView countries (public: active only)
viewCurrency, viewCurrenciesView currencies (public: active only)
viewPaymentProvider, viewPaymentProviders, viewPaymentInterfacesView payment config
viewDeliveryProvider, viewDeliveryProviders, viewDeliveryInterfacesView delivery config
viewWarehousingProvider, viewWarehousingProviders, viewWarehousingInterfacesView warehousing config
viewQuotation, viewQuotationsView quotations
viewEnrollment, viewEnrollmentsView enrollments
viewToken, viewTokensView tokens
viewTranslationsView text translations
viewShopInfoView shop configuration (public)
viewWork, viewWorkQueueView work queue
viewEvent, viewEventsView events
viewStatisticsView analytics
viewLogsView system logs

Management Permissions​

ActionDescription
manageUsersFull user management
manageProductsCreate, update, delete products
manageAssortmentsManage categories and collections
manageFiltersManage product filters
manageLanguagesManage languages
manageCountriesManage countries
manageCurrenciesManage currencies
managePaymentProvidersManage payment providers
manageDeliveryProvidersManage delivery providers
manageWarehousingProvidersManage warehousing providers
manageBookmarksManage user bookmarks
manageProductReviewsModerate product reviews
manageQuotationsManage quotations
manageWorkerManage background jobs
managePaymentCredentialsManage saved payment methods

Update Permissions​

ActionDescription
updateUserUpdate user profile
updateUsernameChange username
updateCartModify cart contents
addCartQuotationAdd a quotation proposal to the cart
updateOrderModify order details
updateOrderDeliveryUpdate order delivery
updateOrderPaymentUpdate order payment
updateOrderDiscountManage order discounts
updateOrderItemModify order items
updateProductReviewEdit product reviews
createEnrollmentCreate enrollments
updateEnrollmentModify enrollments
updateTokenModify tokens

Order Lifecycle​

ActionDescription
createCartCreate a shopping cart
checkoutCartProcess checkout
markOrderConfirmedConfirm a pending order
markOrderRejectedReject a pending order
markOrderPaidMark order as paid
markOrderDeliveredMark order as delivered

Authentication​

ActionDescription
loginAsGuestCreate anonymous session
loginWithPasswordPassword authentication
loginWithWebAuthnPasskey authentication
logoutEnd session
logoutAllSessionsInvalidate all tokens
verifyEmailVerify email address
useWebAuthnWebAuthn operations
changePasswordChange own password
resetPasswordReset with token
forgotPasswordRequest reset email
impersonateImpersonate a user
stopImpersonationEnd impersonation
createUserRegister new user
enrollUserEnroll new user

User Actions​

ActionDescription
reviewProductSubmit product review
voteProductReviewVote on reviews
requestQuotationSubmit RFP
answerQuotationRespond to quotation
bookmarkProductBookmark/favorite products
createBookmarkCreate a bookmark
registerPaymentCredentialsSave payment methods
sendEmailSend messages
removeUserDelete user account

Files & Media​

ActionDescription
downloadFileDownload files
uploadUserAvatarUpload avatar
uploadTempFileUpload temporary files
confirmMediaUploadConfirm media upload

Other​

ActionDescription
searchSearch products/assortments
pageViewLog page views
heartbeatUpdate activity
bulkImportBulk import data

Checking Permissions​

In GraphQL Resolvers​

Use the checkResolver decorator:

import { acl } from '@unchainedshop/api';

export default acl.checkResolver('viewUser')(
async (root, { userId }, context) => {
return context.modules.users.findUserById(userId);
}
);

Field-Level Permissions​

Use checkTypeResolver for field-level access control:

import { acl } from '@unchainedshop/api';

export const OrderType = {
delivery: acl.checkTypeResolver('viewOrder', 'delivery'),
payment: acl.checkTypeResolver('viewOrder', 'payment'),
};

Direct Permission Check​

The configured roles instance is available on the resolver context:

const allowed = await context.roles.userHasPermission(
context,
'manageUsers',
[user, { userId }],
);

if (!allowed) {
throw new Error('Permission denied');
}

Custom Roles​

Define a Custom Role​

Pass rolesOptions to startPlatform — the platform configures the roles system with them at boot:

import { startPlatform } from '@unchainedshop/platform';

await startPlatform({
rolesOptions: {
additionalRoles: {
support: (role, actions) => {
// View all orders
role.allow(actions.viewOrder, () => true);
role.allow(actions.viewOrders, () => true);

// Only confirm/reject pending orders
role.allow(actions.markOrderConfirmed, () => true);
role.allow(actions.markOrderRejected, () => true);

// View users but not modify
role.allow(actions.viewUser, () => true);
role.allow(actions.viewUsers, () => true);
},

moderator: (role, actions) => {
role.allow(actions.manageProductReviews, () => true);
role.allow(actions.updateProductReview, () => true);
},
},

// Register custom actions
additionalActions: ['moderateContent', 'viewAnalytics'],
},
});

Assign Roles​

// Via module API
await modules.users.updateRoles(userId, ['support']);
mutation {
setRoles(userId: "user-123", roles: ["support"]) {
_id
roles
}
}

Context-Aware Rules​

Rules can inspect the user, target object, and parameters:

additionalRoles: {
regionManager: (role, actions) => {
// Only view orders from their region
role.allow(actions.viewOrder, async (order, params, context) => {
const user = await context.modules.users.findUserById(context.userId);
return order.countryCode === user.profile?.address?.countryCode;
});
},
},

Permission Evaluation​

Rules are evaluated with OR logic: if any allow rule for an action returns true, access is granted.

User roles → [admin, __loggedIn__, __all__]
↓
For each role, check allow rules for the action
↓
Any rule returns true → ACCESS GRANTED
All rules return false → ACCESS DENIED