I have delegated Bearer Token Validation
to Azure Function Invocation Filter
. It validates the token and gets the claims. Now i'm trying to pass those claims or ClaimsPrincipal
object into Function.
public override Task OnExecutingAsync(
FunctionExecutingContext executingContext, CancellationToken cancellationToken)
{
var handler = new JwtSecurityTokenHandler();
handler.InboundClaimTypeMap.Clear();
principal = handler.ValidateToken(jwtToken,
new TokenValidationParameters
{
ValidateAudience = false,
ValidIssuer = issuer,
ValidateIssuerSigningKey = false,
SignatureValidator = (t, param) => new
JwtSecurityToken(t),
NameClaimType = "sub"
}, out var token);
}
I see a dictionary called Properties
in FunctionExecutingContext
. But as per the documentation it is used for passing data between filters.
So executingContext.Properties["claims"] = principal;
doesn't pass data to function.
We could achieve it with RouteData
in WebAPI but not sure if it's possible to do it in Azure Functions. Any help is highly appreciated.