A starter template for implementing JWT token from ASP.NET Core Identity project and applying that JWT token authentication on React TS application
This is a basic implementation of role-based access control which can be fully controlled from an Admin panel instead of hard coding the permissions inside of your code. This implementation covers the scenario of a basic microservice based system where the users can be having different roles and based on their roles, their permission will be different accross both in the Client side and in the Server side.
This repository uses a number of frameworks and libraries to work:
- ReactJS - A JavaScript library for building user interfaces.
- TypeScript - TypeScript is a strongly typed programming language that builds on JavaScript, giving you better tooling at any scale.
- Redux - A Predictable State Container for JS Apps.
- Firebase/Storage - Cloud Storage for Firebase is a powerful, simple, and cost-effective object storage service built for Google scale.
- ASP.NET Core Identity - Is an API that supports user login functionality. Manages users, passwords, profile data, roles, claims, tokens, email confirmation, and more.
- CQRS pattern - CQRS stands for Command and Query Responsibility Segregation, a pattern that separates read and update operations for a data store.
- SQL Server - SQL Server Express is a free edition of SQL Server
- Swagger UI - Swagger (OpenAPI) is a language-agnostic specification for describing REST APIs. It allows both computers and humans to understand the capabilities of a REST API without direct access to the source code.
The database file (App_Data/AspNetIdentity-Localdb) is already in the project, so you do not have to worry about setting up the database and running the application locally. You can simply run the application through Visual Studio or VS Code IDE.
To run server
cd API/src/RS_Services_API
dotnet restore
dotnet run
Verify the deployment by navigating to your server address in your preferred browser.
http://localhost:5000/swagger/index.html
If you want to create your database by yourself, here is what need to do.
- Open the file appSettings.json inside the RS_Services_API folder and provide your connection string.
"DefaultConnection": "YOUR CONNECTION STRING"
- Then run the following command for migrations.
dotnet ef migrations add InitialCreate --context ProfileDbContext
dotnet ef database update --context ProfileDbContext
- If dotnet-ef tool is not installed then
dotnet tool install --global dotnet-ef
To run client
cd React_Client
npm install
npm start
Verify the deployment by navigating to your client address in your preferred browser.
http://localhost:3002/
The source code for the site is licensed under the MIT license, which you can find in the LICENSE.md file.