I'm building a Blazor Server Application with Windows Authentication and I host it as a Windows Service. By default, application logs me in automatically based on my Windows credentials. However, I need it to always prompt for user's login and password. I found one article in SO in which someone claimed that forcing application to prompt for Windows login is not possible, but it was some time ago. I wonder if anything has changed in that matter. I couldn't find any information on that topic.
I haven't done anything in Blazor yet, but I know how Windows Authentication works.
Windows Authentication works by sending a 401 response to the browser with the Authentication header set to Negotiate, which prompts the browser to re-send the request with the user's credentials - but only if the website is in the Windows Trusted Sites.
So you could remove the site from Trusted Sites, which would force the browser to ask for credentials rather than automatically sending the credentials.
Or somehow intercept the second request and send a second 401 response, which the browser will interpret as a failed login and it would prompt for credentials.
But even then, the user gets the default, ugly credential prompt from the browser.
The whole reason to use Windows Authentication is to not have to type in your credentials. If you want the user to type in their credentials every time, then you're better off not using Windows Authentication. Create a pretty login page that asks for credentials and verify the credentials yourself. This is essentially LDAP authentication. This question/answer might help you get there: Implementing authorization based on LDAP in blazor
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With