-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Description
Does security stamp validation occur with bearer tokens when using Identity API endpoints?
For example, consider the following sample setup:
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddAuthorization();
builder.Services.AddIdentityCore<AppUser>()
.AddEntityFrameworkStores<AppDbContext>()
.AddApiEndpoints();
builder.Services.AddAuthentication()
.AddBearerToken(IdentityConstants.BearerScheme);
builder.Services.Configure<SecurityStampValidatorOptions>(options =>
{
options.ValidationInterval = TimeSpan.FromMinutes(1);
});
var app = builder.Build();
app.UseAuthentication();
app.UseAuthorization();
app.MapIdentityApi<AppUser>();I would anticipate using the following code would prevent this user from accessing endpoints with RequireAuthorization after several minutes with the configured ValidationInterval for SecurityStampValidatorOptions.
await userManager.SetLockoutEndDateAsync(user, DateTimeOffset.UtcNow.AddHours(12));
await userManager.UpdateSecurityStampAsync(user);However, it doesn't appear to work. Looking at #47228 authored by @halter73 it makes reference to both security stamp validation and bearer tokens. But is that only during token refresh, i.e. ISecurityStampValidator only works with cookies?
Just trying to get my head around the concepts as the documentation is lacking in this respect and possibly needs addressing if my assumptions are incorrect.