Skip to content

reyan-ahmed/Authentication

Repository files navigation

Authentication

Simple project which will provide Authentication with JWT Token

Report Issues release license Linkedin


Logo

Authentication & Authorization with JWT Token

This project is to support those who is new in identity & want to use **jwt** token Authentication.
Explore the docs »

View Demo coming soon · Report Bug · Request Feature

Table of Contents
  1. Getting Started
  2. About The Project
  3. Usage
  4. Roadmap
  5. Contributing
  6. Contact
  7. Acknowledgements

Getting Started

First, Clone this project or fork. And make sure you have dotnet core install. This project is created 3.1. Please make sure you update the connection string in appsettings.

How to Build Project

First, Clone this project or fork. Please run the below mentioned commands to build it properly.

  1. Clean
  dotnet clean
  1. Restore dependencies
  dotnet restore
  1. Build Project
  dotnet build

How to Run Entity Core

Second, Add migration first then we will create database. As we are using separate project for Identity (DBContext file) . Then we need to explicitly mentioned where is our DBContext file (-c ) and what is our starting application (-s ). I want to keep migration file inside my Data/Migration folder that's why I mentioned (-o Data/Migraions). Please run below mentioned commands.

  1. Add Migration
dotnet ef migrations add Initial -p Identity -s Application -c ApplicationDbContext -o Data/Migraions
  1. Create database
dotnet ef database update -p Identity -s Application -c ApplicationDbContext 

How To Run This Project

We are successfully build and create a database. Now, we can run this project. Please run following command.

  1. Run project with watch. Any changes no need to re-build the project
dotnet watch run 

OR

  1. Simply Run
dotnet run

About The Project

I am currently working on it. This will help to seperate the identity framework and handle user and role separately. I also added JWT token, So later if we want to change MVC application to Web API then just add identity class library and run some commands and we good to go.

What is identity

ASP.NET Core Identity framework in brief. ASP.NET Core Identity framework is used to implement forms authentication. There are many options to choose from for identifying your users including Windows Authentication and all of the third-party identity providers like Google, Microsoft, Facebook, and GitHub etc

User

We have Identity User table where all user data will be store. But we created Application user to extend the default identity user property. Like First Name & Last Name there can be add different properties depend on the requirements. I Added only two property to give an example.

Role

We are using here Identity Role default one. As I don't find anything which we need to modify in the defaulty Identity Role. Name and Id is enought to use role. All roles will be store inside Identity Role table.

Permision

I have created Admin role which have the permision to add update and delete role and as well as the users. There is another role called default which I will use for the normal user.

Seed Default Data

I am seeding some data by default so when you will run this application. Super admin and admin role will be automatically inserted into the database.

Coming Soon

I am working on few things, which is a part of my roadmap for this project.

  1. Create Online demo for this project.
  2. I want to make it as a Shell so mostly 90% need login and role mininum so just use it as a shell and start create your application using it.
  3. User Profile
  4. Edit of the Role and User
  5. Edit and assign new role to existing user
  6. Many More :)

Usage

No need to create authentication from scratch, This project help you to start not from zero. It already have authentication with JWT token. You may use the MVC main application or create your own WEB API. But using identity class library, It may help you alot and this start-up and program file from main application. It have small small things which will save alot of time. Like seeding data, JWT, Role and user managment.

Roadmap

See the open issues for a list of proposed features (and known issues).

Contributing

Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request