1
我已將Bearer Token Validation
委託給Azure Function Invocation Filter
。它驗證令牌並獲得聲明。現在我試圖將這些索賠或ClaimsPrincipal
對象轉換爲函數。將數據從Azure函數過濾器傳遞到函數
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);
}
我看到一個在FunctionExecutingContext
稱爲Properties
字典。但是按照文檔它用於在過濾器之間傳遞數據。因此executingContext.Properties["claims"] = principal;
不傳遞數據到功能。
我們可以在WebAPI中使用RouteData
來實現它,但不確定是否可以在Azure函數中使用它。任何幫助,高度讚賞。
謝謝。我正在使用Azure函數。類是靜態的。所以我認爲每次調用函數都不可能有新的類實例。 – Venky