Blazor with Keycloak OIDC

Viewed 113

I am currently trying to implement authentication in my Blazor-Webapp using OIDC via Keycloak. The login-url gets (mostly) correctly generated and the user is being redirected. The problem is that in the URL, the parameter prompt=none is set, which leads to no-login prompt and an immediate redirect back to the Webapp with error=login_required as the response in the url.

As I've read from this github-issue, it seems that this is intended so that silent-authentication can be tried first. Yet, I would expect that when this fails, that the user will get redirected to the login prompt anyways - which isn't the case (and the comments in the issue didn't help me any further). I added authentication via the code-snippet below:

// Program.cs
builder.Services.AddOidcAuthentication(options =>
{
    builder.Configuration.Bind("Oidc", options.ProviderOptions);
});

// appsettings.json
{
  "Oidc": {
    "Authority": "http://localhost:8080/realms/xxxxxx",
    "ClientId": "xxxxxxxxx",
    "PostLogoutRedirectUri": "http://localhost:65283",
    "DefaultScopes": [
      "roles"
    ],
    "ResponseType": "code"
  },
  "DetailedErrors":  true
}
0 Answers
Related