4

アイデンティティを拒否するにはどうすればよいですか? 私のクラスは 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);
}
4

1 に答える 1

3

問題を再現できませんでした。OnValidateIdentity の実装が同じであることを確認できますか?

        OAuthBearerOptions = new OAuthBearerAuthenticationOptions()
        {
            Provider = new OAuthBearerAuthenticationProvider
            {
                OnValidateIdentity = async ctx =>
                    {
                        ctx.Rejected();
                    }
            }
        };
于 2013-10-24T17:02:23.277 に答える