CleanArchitectureWithBlazorServer icon indicating copy to clipboard operation
CleanArchitectureWithBlazorServer copied to clipboard

Changing client side js authentication to server side

Open nammadhu opened this issue 1 year ago • 1 comments

Hi Neozhu, Please tell me how to do server side authentication instead of clientside javascript authentication in this repo. I know most of code already exists, but how to do switch to serverside instead of clientside.

*In current code under loginwithgoogle() js please add VAR before client variable

Thanks, Madhu

nammadhu avatar Mar 02 '24 09:03 nammadhu

are you suggesting using a third-party authentication system like Google Auth or another OAuth2 provider?

neozhu avatar Mar 02 '24 10:03 neozhu

Yes, instead of doing clientside externalauth.js , wanted to use server side completely by using . AddAuthentication.AddGoogle() , currently that code is written but not used . So want to know how to use that. With that only we can use clientsecret and make application more secured. Current externalauth.js mode anyone can change locally username & pass

nammadhu avatar Mar 03 '24 12:03 nammadhu

I will refactor the integration of Google Authentication and Microsoft Authentication if I have the time.

neozhu avatar Mar 04 '24 03:03 neozhu

After reviewing the relevant documentation for Microsoft.AspNetCore.Authentication.MicrosoftAccount and Microsoft.AspNetCore.Authentication.Google, I learned that these libraries can only be used with ASP.NET Core MVC/Razor projects and must be integrated with MicrosoftIdentityUI. My project's login page is completely custom-developed. Of course, it's possible to achieve this using the official project templates that come with Visual Studio, since they use Razor Pages. I guess I have no choice but to give up.

neozhu avatar Mar 07 '24 13:03 neozhu

I really appreciate your prompt statements!!! I will try if I can do.... Actually earlier i was half-done with intgration on your branch only but it was little messy,so deleted & asked you... Anyhow still I will make a re-try... Great... Lets work together... Once again I appreciate you a lot...

nammadhu avatar Mar 07 '24 23:03 nammadhu

You can refer to the standard Blazor web app template in Visual Studio, where the login page is implemented using razor pages and IdentityRevalidatingAuthenticationStateProvider. Based on this, you can definitely use the MVC model to implement all OAuth2 authentication logins. Of course, it uses cookies to save authentication information. Implementing this in my project is also possible but would require a significant amount of work. If you're interested, you might want to give it a try.

neozhu avatar Mar 08 '24 00:03 neozhu