https://github.com/viveksite/rbac_system
This project is a implementation of Role Based Access Control System in NodeJS and ExpressJS with Typescript
https://github.com/viveksite/rbac_system
authentication authorization expressjs nodejs typescript
Last synced: 5 months ago
JSON representation
This project is a implementation of Role Based Access Control System in NodeJS and ExpressJS with Typescript
- Host: GitHub
- URL: https://github.com/viveksite/rbac_system
- Owner: VivekSite
- Created: 2024-11-30T06:06:54.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-11-30T09:59:43.000Z (over 1 year ago)
- Last Synced: 2025-03-30T17:07:09.836Z (about 1 year ago)
- Topics: authentication, authorization, expressjs, nodejs, typescript
- Language: TypeScript
- Homepage: https://rbac-system-4mq8.onrender.com
- Size: 73.2 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
### This project is the implementation of Role based access control. and this repository contains only backend code.
# Run the code locally
- Clone the repository: `git clone https://github.com/VivekSite/rbac_system.git`
- Install all the dependencies: `yarn install`
- Create .env file and add required variables
`cp .env.example .env`
- ```
NODE_ENV=development
PORT=8080
MONGO_URI=mongodb://localhost:27017/rbac_server
ALLOWED_ORIGINS=http://localhost:3000,http://localhost:4200 # add more origins separated by commas
ACCESS_TOKEN_SECRET=****************************
REFRESH_TOKEN_SECRET==****************************
HASH_SECRET==****************************
OTP_SECRET==****************************
EMAIL_SENDER=example@exampl.com
EMAIL_PASS_KEY='**** **** **** ****'
```
- Build and start the application `yarn dev`
- Application uses JWT token for authentication and authorization. I'm using browser cookies to store the access and refreshToken. accessToken will get expired in 1hour and refreshToken will expiresIn 30day.
- For role based authentication I'm storing role information in the jwt payload and whenever user makes request to backend I'm checking is user has permission to access particular resouces or not.