-
-
Notifications
You must be signed in to change notification settings - Fork 733
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Authorization with electron.net #788
Comments
Can you scrabble together a repo that showcases roughly what you want? Then I can take over and see what to do to make this dream come true! |
I will do so today. Cheers for the assist. Here's the challenges as I see them.
The issue is that the blazor app running in electron.net is either http by default or even if you make it use https, you have the issue of a self-signed cert in your embedded blazor app. The only way I can imagine this working would be to login using electron, but of course now you would need a means of
I might be overthinking this, and thus why I'm raising the question here: to see if anyone has faced this or has opinions on the best and most secure way to handle this. I'll put some code together today and fwd the repo through. |
Okay, so after attempting to build out an example of the source code I was after, I noted something in the above tutorial for an electron app which I had not noted previously. I was under the erroneous impression (not sure why I assumed this) that when the electron app called Auth0 (or whatever identity provider) it was using https for its callback url, which is not so (or at least not in the above example).
Realising that the electron app (be it electon js or electron.net) is just listening on http for the auth response anyway, I assumed there was very little value in attempting to bring electron into the mix since it was no more or less secure than letting the blazor app handle authentication on http. So, I simply focused on getting the blazor app inside to talk to Auth0. I was able to do so by using the blazor app's url port on localhost as the redirect url when Auth0 had completed authentication ( So, I simply deicded to treat the embedded blazor app in my electron.net app as if it were a standard web app and Auth0 setup to act accordingly. To test and debug this, I ran the app as a normal web app, got the auth0 authentication working as per their instructions, and then tweaked it by running it up inside electron.net. I just needed the embedded asp.net core app's Now, you'd think at this point it would be quite easy, but no. What I found was that using http vs https matters a LOT to asp.net core in regards to authentication, and disabling https in authentication (particularly as related to cookies) is NOT as straightforward as you might think. After much googling and testing, I found the sweet spot for my program.cs and the cookie setup required:
This allowed the proper cookies to be retrieved / set as related to authentication. Feedback and comments most welcome. |
Since you communicate with your localhost there is no point in HTTPS anyway. The secure tunnel only makes sense when going outside. Glad you got a working solution! |
@domingoladron Thanks for the solution. I'm having trouble understanding what you meant by
What does the code for that look like? Maybe you'd be able to share the authentication code in full? I'm working on authorizing an MVC app with Electron.NET. Also, it was pleasant to read your articulation. You're a great writer. |
Hey there, Cheers for the nice reply. It's been a wee while, so give me a day or so to dust off that code and get it running again, but yes, I think I can help. |
I've been trying this for a week and still little success.
Auth for a blazor server app, np. Auth for an electron native app has a few more working parts but still doable. Put them together...not so easy.
Has anyone successfully bridged the authentication and authorization between the native app aspects in js /ts and the web aspects in .net core?
I want users to login to my native app via say Auth0, then with the IUserPrincipal, interact with the blazor app using said creds. I can't imagine I'm the only poor sod chasing this dream.
I could also just have them log into the web app using normal web flows inside my asp.net core app, but of course this may raise up security concerns (though not sure what those would be).
Looking for ideas, advice, opinions, etc on such Auth models in a hybrid system such as electron.net.
The text was updated successfully, but these errors were encountered: