This repository is a simple example demonstrating User-Based Access Control (UBAC) with Payload. It shows how to implement UBAC across various collections using Payload CMS.
To set up the project locally, follow these steps:
- Clone the repository:
git clone https://github.com/tigersoft6084/ubac-demo.git
- Navigate to your project directory and copy the environment file:
cd ubac-demo && cp .env.example .env
- Install dependencies and start the development server:
Alternatively, if you prefer Docker, see the Docker section below.
yarn && yarn dev
- Open your browser and access the admin panel at http://localhost:3000/admin.
- Use the form on the page to create your first admin user.
To use Docker for setting up the project, follow these instructions:
- Complete the first two steps from the Install section. The
docker-compose
file will utilize the.env
file located in your project root. - Start the Docker environment:
docker-compose up
- Proceed with steps 4 and 5 from the Install section to access the admin panel and create your first admin user.
Docker simplifies the process of getting the project running and ensures a consistent development environment across different machines.
To configure user permissions in the admin panel:
- Go to the admin's user management page.
- Understand the available user roles:
Owner
role can read, create, update, or delete any users, including themselves.Staff
role can read or update their own user information. Note: TheRole
andPermissions
fields can only be modified by users with theOwner
role.
- If you are logged in as an
Owner
, you can edit every user's permissions:- Navigate to a user's profile from the users list.
- Modify the checkboxes under the
Permissions
section to grant or revoke permissions on specific collections.
- Click the "Save" button to apply the changes.