ASP.net Core MVC Login

Viewed 857

I am making a website with ASP.net core MVC. I want the website just to have one admin login to manage a database that manages the layout of the page. How do I have only one use without Microsoft Identity that includes everything for a millon users. I just want to have one login for a user (me) to live edit a website layout via a database, everyone that visits the page should never have to login. Thanks beforehand!

/* UPDATE */

I have managed to successfully add a userprincipal to a user that logs in with the use of claims. I have a question: How do I safely store the passwords and how do I claim a password? What ClamType do I use for password validation?

Best regards Max

3 Answers

If you'd like to implement and integrate a simple authentication and authorization mechanism in your ASP.NET Core MVC app without ASP.NET Core Identity, you can try to implement and use a custom cookie-based authentication based on your actual requirement/scenario.

For more information about "Use cookie authentication without ASP.NET Core Identity", please check:

https://docs.microsoft.com/en-us/aspnet/core/security/authentication/cookie?view=aspnetcore-5.0

And it shared an example app in above doc, you can refer to the sample code to achieve same in your app.

https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/security/authentication/cookie/samples/3.x/CookieSample/Pages/Account/Login.cshtml.cs#L116

This might help if you don't want to go for Microsoft.Identity. You can have a separate route (for eg: /#/admins) This page will only be visible to the 'Admin' user. Now, admin can be authenticated either via having one property for the user for Admin or by having different admin credentials.

I got it working! I used this tutorial on Youtube! It shows you have to use claims and use cookies, I made a special variant of it with sha256 + salt password encryption. Thanks everyone for your time and help!

Related