Asp.net core MVC windows authentication using login page

809 Views Asked by At

I have built a base web app using aps.net core 7. I am using windows auth. all is working but I am getting an alert popup to sign into the web app at top of browser window.

This is functionally ok but I would prefer to have a login form. Is this possible with this configuration?

Thanks

All is working functionally but I dont know where to start to configure a login form.

1

There are 1 best solutions below

3
exeC13 On

while being curious on why you are required to move the login details from the browser-popup to a page I feel like you might be taking a wrong turn here. Please let me elaborate on that:

An advantage of Windows auth is that you do not need to explicitly authenticate yourself again against e. g. internal web-apps. You are already running your favorite browser in the context of your authenticated windows user. My guess is that you are getting the login-popup from your browser because there is no group-policy or setting in place that marks your web-apps URL as trusted. For details on getting rid of the login-popup from your browser you might want to start here.

If you are interested in non-windows-auth mechanisms (where you would use your requested login page) I would advise you to have a look at the Introduction to Identity on ASP.NET Core article. You can also easily create a new web-app using Individual User Accounts as Authentication type to get some boilerplate code with the login-functionality you were asking for. But again - this is not the windows-auth way of doing things but a different auth-concept.

If you want to stick with windows-auth and reach the point where you need fine-grained permissions you might consider using Directory Services if you want to manage permissions via the Active Directory (Ref.: How to add Roles to Windows Authentication in ASP.NET Core) or dive into something like JWT with your own structure behind it.