Fail closed on malformed local auth
This commit is contained in:
@@ -253,6 +253,17 @@ builder.Services.AddAuthentication(options =>
|
||||
context.Token = cookieToken;
|
||||
}
|
||||
|
||||
return Task.CompletedTask;
|
||||
},
|
||||
OnTokenValidated = context =>
|
||||
{
|
||||
var userId = LocalAuthIdentity.GetRequiredUserId(context.Principal);
|
||||
if (userId is not null)
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
context.Fail("Local tokens must include a subject/nameidentifier claim.");
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user