Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

Blazor Web App and Duende IdentityServer keeps getting logged out

$
0
0

I've set up the following,

  • Duende IdentityServer (IDP)
  • API
  • Blazor Web App (.Net 8)The Web App consists of a Server and Client project.

When logging in I get authenticated and able to retrieve data from the API. All is good. The problem is that I get logged out if the user is idle for about 5 minutes.

I've set up offline_access for the use of reqest token, but whatever changes I try - I still get logged off having 5 min of idle time.

I've even set the access token lifetime to 2 hours on the IDP config as a workaround, but that seems to have no effect. A little bit of idle time and I'm routed back to the login page of the IDP.

AccessTokenLifetime = 7200
IdentityTokenLifetime = 7200

Not quite sure where to look anymore. Anyone who can shed some light on what I am missing?

Here's some of the most relevant setup

--------- Duende IDP Config --------------------------

new Client{    ClientId = "test.blazor.webapp",    ClientName = "TestApp",    RequireClientSecret = true,    AllowedGrantTypes = GrantTypes.Code,    RedirectUris = configuration.GetSection("BlazorWebApp:RedirectUris").Get<string[]>(),    FrontChannelLogoutUri = configuration.GetSection("BlazorWebApp:FrontChannelLogoutUri").Get<string>(),    PostLogoutRedirectUris = configuration.GetSection("BlazorWebApp:PostLogoutRedirectUris").Get<string[]>(),    AccessTokenLifetime = 7200,               IdentityTokenLifetime = 7200,          AllowOfflineAccess = true,    AllowedScopes = { "openid", "profile", "roles", "testapi" }},

------------Server Blazor-----------------------------------

builder.Services.AddRazorComponents()    .AddInteractiveServerComponents()    .AddInteractiveWebAssemblyComponents();builder.Services.ConfigureAuthentication(builder);builder.Services.ConfigureCookieOidcRefresh(CookieAuthenticationDefaults.AuthenticationScheme, OpenIdConnectDefaults.AuthenticationScheme);builder.Services.AddDistributedMemoryCache();builder.Services.AddCascadingAuthenticationState();builder.Services.AddScoped<AuthenticationStateProvider, PersistingAuthenticationStateProvider>();builder.Services.AddAuthorization();

------------Server Blazor (ConfigureAuthentication)-----------------------------------

.AddOpenIdConnect(OpenIdConnectDefaults.AuthenticationScheme, options =>{  options.Authority = builder.Configuration.GetSection("IDP:Authority").Get<string>();  options.ClientId = "test.blazor.webapp";  options.GetClaimsFromUserInfoEndpoint = true;  options.MapInboundClaims = false;   options.TokenValidationParameters.NameClaimType = JwtRegisteredClaimNames.Name;  options.TokenValidationParameters.RoleClaimType = "role";  options.ResponseType = OpenIdConnectResponseType.Code;  options.SaveTokens = false;    options.Scope.Add(OpenIdConnectScope.OfflineAccess);  options.Scope.Add(OpenIdConnectScope.OpenIdProfile);  options.Scope.Add("roles");  options.Scope.Add("testapi");  options.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;  options.CallbackPath = new PathString("/signin-oidc");  options.SignedOutCallbackPath = new PathString("/signout-callback-oidc");  options.RemoteSignOutPath = new PathString("/signout-oidc");});  builder.Services.AddOpenIdConnectAccessTokenManagement();  return services;}

----------------Client Blazor -------------------------------

var builder = WebAssemblyHostBuilder.CreateDefault(args);builder.Services.AddAuthorizationCore();builder.Services.AddCascadingAuthenticationState();builder.Services.AddSingleton<AuthenticationStateProvider, PersistentAuthenticationStateProvider>();builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });await builder.Build().RunAsync();

Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>