Skip to content

A simple cookie based authentication example using Asp.net core.

Notifications You must be signed in to change notification settings

mail4hafij/CookieAuthentication

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CookieAuthentication

A simple cookie based authentication example using Asp.net core. The drawback of cookie based authentication is that, every Cleint session will be saved in the server memory. Therefore, if you are planning to design a stateless architecture or run your API in multiple virutal machines behind a load balancer with no session persistancy, your rest API will not work since client requests will be distrbuted randomly to those virtual machines. Thereby, your API request with a given cookie may not be served by the same virtual machine. In case you want a stateless implementation then always use JWT based authentication (please find the repo here https://github.com/mail4hafij/JWTAuthentication).

How to run locally

After you build and run the project, use Postman (or other similar tools you are familier with) to make a login POST request to https://localhost:44322/api/Login. You should then get back a cookie value which will be used to send your api GET request to https://localhost:44322/api/status.

Please do all the neccessary changes as you see it fit (i.e., email, password authentication with your database in SignInManager class).

Conceptual model

About

A simple cookie based authentication example using Asp.net core.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages