I’ve defined a custom AuthenticationHandler<T>
. For testing purposes I implemented like this:
protected override async Task<AuthenticateResult> HandleAuthenticateAsync() {
return AuthenticateResult.Fail("foo", new() {
Items = {
{ "reason", "some message" }
}
});
When running in the debugger I see it call that method, and then immediately after it hits the HandleChallengeAsync
method. However, the properties parameter that HandleChallengeAsync
receives has Items
with a count of 0. Why isn’t it getting the property I defined?
I don’t think I messed up the order of stuff in program.cs, but this is what I did:
builder.Services
.AddAuthentication(PasetoToken.Scheme)
.AddScheme<AuthenticationSchemeOptions, PasetoBearerHandler>(PasetoToken.Scheme, x => x.Validate());
builder.Services
.AddAuthorization(x => x.FallbackPolicy = new AuthorizationPolicyBuilder()
.RequireAuthenticatedUser()
.Build());
var app = builder.Build();
app
.UseRouting()
.UseAuthentication()
.UseAuthorization()
.UseExceptionHandler()
.UseEndpoints(x => ...);