https://github.com/kant2002/simpleidentity
https://github.com/kant2002/simpleidentity
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/kant2002/simpleidentity
- Owner: kant2002
- License: mit
- Created: 2022-06-10T12:07:28.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2022-06-10T12:07:33.000Z (about 4 years ago)
- Last Synced: 2025-07-07T08:07:41.995Z (about 1 year ago)
- Language: C#
- Size: 30.3 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
Simple Identity
===============
This application shows one scenario which not very well covered by ASP.NET Identity Core in my opinion.
# Assumptions
- There existing database for storing login information.
- There lowered security requirements from the client, and it not see all modern security as very important
- Application is limited to small number (<10) users within same small org.
- All user validation logic happens on the DB
# Goals
- Do not try to change mind of other people who have some architectural predisposition
- Provide as much security as possible without rolling your own custom solution
- Do not mess with complexity of store interfaces.
# Solution
Instead of writing custom persistence stores which seems to be require you to implement all of them,
I propose much simpler variant where you override `UserManager`.
Because developer write code using that class, they are much more familiar with these API, it's immidiately
clear what method you should override, and all these customizations contained to single class.
Cookies and all security tokens still created by ASP.NET Identity and all check still performed by ASP.NET AuthZ/AuthN pipeline.
# Example
= Make sure that SSDT installed in Visual Studio, otherwise you have to manually create DB and publish scripts.
- Open solution in Visual Studio
- Expand SimpleIdentity.Db project and double-click on Debug.publish.xml
- Set SimpleIdentity as startup project and run.
Minimal work to supprort this scenario is to have following classes.
- `UserManager`
- `SimpleSignInManager`
- `IdentityContext` just to trick Identity.
Other notes
- You do not even need custom `ApplicationUser` if fields from `IdentityUser` is enough for you.
- You do not derive your `DbContext` from IdentityDbContext since it would not be used.
- You probably would not need `IdentityContext` without `ApplicationUser` and you can use `IdentityDbContext` directly in the Program.cs