You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Couple of limitations with regards to customizing the AuthorizeAttribute:
Cannot provide Roles due to IAPI0002
Cannot provide AuthenticationSchemes due to IAPI0002
Regarding the AuthenticationSchemes, I would like to be able to accept Basic authentication in exchange for a JWT. JWT Bearer authentication would be accepted by all other endpoints.
AuthenticationSchemes Example
public sealed partial record GetTokenQuery();
[Handler]
[Tags("Auth")]
[MapGet("/auth/token")]
[Authorize]
public static partial class GetTokenHandler
{
private static readonly string[] AuthenticationSchemes = ["Basic"];
internal static void CustomizeEndpoint(IEndpointConventionBuilder endpoint)
=> endpoint.RequireAuthorization(new AuthorizationPolicy(new List<IAuthorizationRequirement>{ new DenyAnonymousAuthorizationRequirement() }, AuthenticationSchemes));
private static ValueTask<Ok<TokenResponse>> HandleAsync(GetTokenQuery query, ClientAuthorizationService clientAuthorizationService, CancellationToken cancellationToken)
{
var token = clientAuthorizationService.CreateToken("foo");
return ValueTask.FromResult(TypedResults.Ok(token));
}
}
The text was updated successfully, but these errors were encountered:
Couple of limitations with regards to customizing the
AuthorizeAttribute
:Roles
due to IAPI0002AuthenticationSchemes
due to IAPI0002Regarding the
AuthenticationSchemes
, I would like to be able to acceptBasic
authentication in exchange for a JWT. JWTBearer
authentication would be accepted by all other endpoints.AuthenticationSchemes Example
The text was updated successfully, but these errors were encountered: