アイデンティティを拒否するにはどうすればよいですか? 私のクラスは OAuthBearerAuthenticationProvider から継承し、ValidateIdentity のオーバーライドがありますか?
context.Rejected(); を設定してみました。または context.SetError(); 例外をスローしますが、コントローラーは引き続き呼び出されます。OAuthBearerAuthenticationHandler は私のクラスを呼び出すので、セットアップが正しいことがわかります。
私の現在の失敗したコード
public void ConfigureAuth ( IAppBuilder app )
{
// Enable the application to use a cookie to store information for the signed in user
// and to use a cookie to temporarily store information about a user logging in with a third party login provider
app.UseCookieAuthentication(new CookieAuthenticationOptions());
app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);
// Enable the application to use bearer tokens to authenticate users
app.UseOAuthBearerAuthentication ( new OAuthBearerAuthenticationOptions ()
{
Provider = new OAuthBearerAuthenticationProvider ()
{
OnValidateIdentity = async ctx => { ctx.Rejected (); }
}
} );
app.UseOAuthBearerTokens(OAuthOptions);
}