Skip to content
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

Authentication through Azure AD (Microsoft EntraID) does not work #850

Open
ThomasStarnes opened this issue May 3, 2024 · 3 comments
Open
Labels

Comments

@ThomasStarnes
Copy link

  • Versions:

    • Electron.NET: 23.6.2
    • .NET: 7.0
    • Node.JS: 20.12.2
  • Target: Windows

I'm working on a Blazor Server app and have been tasked with creating a desktop version of the app. I have been trying to use Electron.NET, but I am running into issues when authenticating through Azure AD while using Electron.NET. I'm receiving the following error:

stdout: fail: Microsoft.AspNetCore.Server.Kestrel[13] Connection id "0HN2V44AL6L5H", Request id "0HN2V44AL6L5H:00000002": An unhandled exception was thrown by the application. System.Exception: An error was encountered while handling the remote login. ---> System.Exception: Correlation failed. --- End of inner exception stack trace --- at Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler1.HandleRequestAsync() at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication1 application)

When I remove the authentication service, or I do not use Electron, it works. It seems to be caused by the cookie "SameSite=None" since the secure cookie is not set to secure.

I have tried adding a cookie policy to the app service by using the following:
app.UseCookiePolicy(new CookiePolicyOptions { MinimumSameSitePolicy = SameSiteMode.Lax });
but this did not fix my issue. I also tried adding it to the authentication service:
builder.Services.AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme) .AddCookie(options => { options.Cookie.SameSite = SameSiteMode.Lax; }).AddMicrosoftIdentityWebApp(builder.Configuration.GetSection("AzureAD")); but this also did not work

Steps to Reproduce:

  1. Register an app on Azure -> Microsoft EntraID
  2. Add Azure AD authentication to the app builder.Services.AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme) .AddMicrosoftIdentityWebApp(builder.Configuration.GetSection("AzureAD"));
  3. Run app and log in via Microsoft account.
  4. Set up electron
  5. Run app again and receive error message instead of login screen
@umitkara
Copy link

Hi. Having the same issue with OIDC and IdentityServer4 instead of AzureAD.

@LapinskasL
Copy link

@umitkara Did you ever solve your issue?

@umitkara
Copy link

umitkara commented Jul 5, 2024

@umitkara Did you ever solve your issue?

Hi. Sorry for late response. Unfortunately no.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants