ownerAc as there is adminAc

I want to know if there is ownerAc , memberAc and where to import it from?
How do I use it @Better Auth @Ping
9 Replies
Better Auth
Better Auth4w ago
You can indeed use ownerAc and memberAc (along with adminAc) to create your roles. However, note that you must import them from the correct access submodule rather than directly from "better-auth/plugins". For example, one correct approach is:
import { createAccessControl } from "better-auth/plugins/access";
import { defaultStatements, adminAc, memberAc, ownerAc } from "better-auth/plugins/organization/access";

const statement = { ...defaultStatements } as const;
const ac = createAccessControl(statement);

const admin = ac.newRole({
...adminAc.statements,
// additional custom permissions, if needed
});

const member = ac.newRole({
...memberAc.statements,
});

const owner = ac.newRole({
...ownerAc.statements,
});
import { createAccessControl } from "better-auth/plugins/access";
import { defaultStatements, adminAc, memberAc, ownerAc } from "better-auth/plugins/organization/access";

const statement = { ...defaultStatements } as const;
const ac = createAccessControl(statement);

const admin = ac.newRole({
...adminAc.statements,
// additional custom permissions, if needed
});

const member = ac.newRole({
...memberAc.statements,
});

const owner = ac.newRole({
...ownerAc.statements,
});
In this setup, you use createAccessControl with the defaultStatements (which sets the basic resource/action definitions) and then extend those with each role’s specific capabilities from adminAc, memberAc, and ownerAc. This is the recommended way to set up role-based access control within Better Auth [1][3]. Keep in mind that if you try importing the symbols from the main plugin entry (e.g. "better-auth/plugins") you might encounter export errors, as seen in some GitHub issues. Make sure you’re using the correct submodule paths as indicated in the documentation and examples [1], [8]. Sources: [1] defaultStatements and defaultAc have an export problem on my project [3] Cannot send organization invite without an owner role [8] Can't accept invitation using acceptInvitation
GitHub
better-auth/better-auth
The most comprehensive authentication framework for TypeScript - better-auth/better-auth
GitHub
better-auth/better-auth
The most comprehensive authentication framework for TypeScript - better-auth/better-auth
GitHub
defaultStatements and defaultAc have an export problem on my projec...
Is this suited for github? Yes, this is suited for github To Reproduce In permission.ts : import { adminAc, defaultStatements, memberAc, ownerAc } from "better-auth/plugins"; The server r...
GitHub
Cannot send organization invite without an owner role · Issue #110...
Is this suited for github? Yes, this is suited for github To Reproduce Follow the installation steps in the docs with the drizzle adapter and postgres database: https://www.better-auth.com/docs/ins...
Hunter
HunterOP4w ago
Can i create superAdmin and give it the adminAc. And how do I do it? @Better Auth
Better Auth
Better Auth4w ago
Yes, you can create a superAdmin role and assign it the adminAc permissions. However, to make sure that the superAdmin is properly recognized as having admin privileges, you need to include "superAdmin" in the adminRoles configuration when initializing the admin plugin. This way, even though superAdmin has adminAc permissions, the framework will treat it as an admin role as expected [1][2]. Sources: [1] Custom admin role not considered an admin [2] Admin | Better Auth
GitHub
Custom admin role not considered an admin · Issue #2015 · better-...
Is this suited for github? Yes, this is suited for github To Reproduce Configure better-auth as per the docs Add the admin plugin Add the adminRoles property with admin and superAdmin as roles Crea...
Admin | Better Auth
Admin plugin for Better Auth
Hunter
HunterOP4w ago
Do I have to create different statement for admin and owner @Better Auth
Better Auth
Better Auth4w ago
You don't necessarily have to create entirely different statements for the admin and owner roles if the default permissions meet your needs. Better Auth provides built-in default statements (like those in adminAc and ownerAc) that handle the common differences between these roles, so you can leverage those rather than building everything from scratch [4]. However, if you need custom behavior for one role versus the other, then it can be beneficial to define custom statements. In that case, you can merge the default statements with your custom ones to only change what’s needed. This way you retain the built-in access control while tailoring permissions for your specific requirements [9]. Let me know if you need more details on how to merge or customize these statements! Sources: [4] Admin | Better Auth [9] Admin plugin ac.newRole unexpectly requires all declared statements
GitHub
better-auth/better-auth
The most comprehensive authentication framework for TypeScript - better-auth/better-auth
Admin | Better Auth
Admin plugin for Better Auth
GitHub
Admin plugin ac.newRole unexpectly requires all declared statemen...
Is this suited for github? Yes, this is suited for github To Reproduce const PermissionStatement = { 'api-docs': ['read'], 'tabletop': ['view', 'play', '...
Hunter
HunterOP4w ago
I added the superAdmin to the admin roles in the admin plugin but I can't list the users and do admin functions @Better Auth
Better Auth
Better Auth4w ago
Hey there! It looks like you're encountering a known issue where adding "superAdmin" to your adminRoles isn’t granting the expected admin permissions (resulting in errors like YOU_ARE_NOT_ALLOWED_TO_LIST_USERS) as documented in our GitHub issue tracking [1]. This behavior started after v1.2.0. As a workaround, you can use the adminUserIds property to explicitly define the user IDs that should have admin access. This should let your "superAdmin" user perform admin actions until a fix is released. Let me know if you have any more questions! Sources: [1] Custom admin role not considered an admin
GitHub
better-auth/better-auth
The most comprehensive authentication framework for TypeScript - better-auth/better-auth
GitHub
Custom admin role not considered an admin · Issue #2015 · better-...
Is this suited for github? Yes, this is suited for github To Reproduce Configure better-auth as per the docs Add the admin plugin Add the adminRoles property with admin and superAdmin as roles Crea...
Hunter
HunterOP4w ago
When do they plan to fix the superAdmin problem @Better Auth
Better Auth
Better Auth4w ago
Hi there! The issue regarding the custom superAdmin role not being recognized was reported and has since been addressed. According to our GitHub records, the bug was closed in an update—so if you're running the latest version of Better Auth, the superAdmin role should be working as intended [1]. If you're still experiencing issues, please double-check that your configuration matches the latest docs. Feel free to reach out if you need further help! Sources: [1] Custom admin role not considered an admin
GitHub
better-auth/better-auth
The most comprehensive authentication framework for TypeScript - better-auth/better-auth
GitHub
Custom admin role not considered an admin · Issue #2015 · better-...
Is this suited for github? Yes, this is suited for github To Reproduce Configure better-auth as per the docs Add the admin plugin Add the adminRoles property with admin and superAdmin as roles Crea...

Did you find this page helpful?