Querystring のトークンから Owin コンテキストを初期化できますか?
Owin をベアラー トークンで使用していますが、HangFire へのアクセスを承認しようとすると、User (Identity) から null が返されます。
しかし、クエリ文字列にトークンがあります。ユーザーを取得するために使用できますか? またはコンテキストを初期化しますか?
コード:
public class HFAuthorizationFilter : Hangfire.Dashboard.IAuthorizationFilter
{
public bool Authorize(IDictionary<string, object> owinEnvironment)
{
var context = new OwinContext(owinEnvironment);
if (context.Authentication.User == null)//always null!?
return false;
return context.Authentication.User.HasClaim(ClaimTypes.Role, "SuperAdmin")
|| context.Authentication.User.HasClaim(ClaimTypes.Role, "Admin");
}
}