Skip to content

SaifSaidi/JWTRefreshToken

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ASP.NET Core API with JWT and Refresh Token

This project is a simple demonstration of how to implement JWT (JSON Web Token) and Refresh Token authentication in an ASP.NET Core API. It provides a basic setup for user registration, login, and token-based authentication.

About the Project

This project is a learning resource for understanding how to secure an ASP.NET Core API using JWT and Refresh Tokens. It includes the following features:

  • User registration and login
  • JWT-based authentication for securing API endpoints
  • Refresh token mechanism for renewing expired JWTs
  • Role-based authorization (Admin and User roles)
  • A simple and clean architecture for easy understanding

Getting Started

To get a local copy up and running, follow these simple steps.

Prerequisites

Usage

You can use a tool like Postman or [Scalar UI] to interact with the API.

API Endpoints

  • POST /api/Auth/Register: Register a new user.
  • POST /api/Auth/Login: Log in a user and get a JWT and refresh token.
  • POST /api/Auth/Refresh-Token: Get a new JWT using a refresh token.
  • POST /api/Auth/Revoke-Token: Revoke a refresh token.
  • GET /api/Users: Get a list of all users (Admin only).
  • GET /api/Users/profile: Get the profile of the current user.
  • GET /api/Admin: Access an admin-only endpoint.

About

JWT and Refresh Token authentication in ASP.NET Core.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages