1
私のWeb API 2プロジェクトでは、JWTベースの認証があります。構成はSignalR 2.0のIAuthenticationFilter
var config = new HttpConfiguration();
app.UseJwtBearerAuthentication(new JwtBearerAuthenticationOptions {/**/});
config.Filters.Add(new MyAuthenticationFilter());
app.UseWebApi(config);
app.UseCors(CorsOptions.AllowAll);
app.MapSignalR();
MyAuthenticationFilter
、着信JWTに基づいてカスタムプリンシパルを構築し、私のコントローラのアクションで、私はthis.User
としてそれにアクセスできるように、要求にそれを添付しています。すべては、フィルタを除いて正常に動作しているがSignalR要求を無視されます。
public class MyHub : Hub {
public override Task OnConnected() {
// here Context.User is ClaimsPrincipal which contain a JWT from Authorization header
// I expect it to be MyCustomPrincipal
return base.OnConnected();
}
}
IAuthenticationFiltter
が無視されるのはなぜ?どうすれば修正できますか?