我想要的:
代码呢:
public void Configuration(IAppBuilder app) { app.UseOAuthAuthorizationServer(new OAuthAuthorizationServerOptions { AuthorizeEndpointPath = "/Authorize", AllowInsecureHttp = true, Provider = new OAuthAuthorizationServerProvider { OnGrantCustomExtension = GrantCustomExtension, OnValidateClientRedirectUri = ValidateClientRedirectUri, OnValidateClientAuthentication = ValidateClientAuthentication, } }); app.UseOAuthBearerAuthentication(new OAuthBearerAuthenticationOptions { Provider = new OAuthBearerAuthenticationProvider { //Handles applying the authentication challenge to the response message. ApplyChallenge=MyApplyChallenge, //Handles processing OAuth bearer token. RequestToken=MyRequestToken, //Handles validating the identity produced from an OAuth bearer token. ValidateIdentity = MyValidateIdentity, } }); app.UseWebApi(new WebApplication3.Config.MyWebApiConfiguration()); }
有什么问题:
OAuthBearerAuthenticationProvider
的3个属性,ApplyChallenge
,RequestToken
和ValidateIdentity
。如何实现3方法?
在令牌认证过程中,我认为是解密访问令牌,从客户端验证令牌,如果令牌已验证,则将令牌的标识放入HttpContext.Current.User
。
OAuthBearerAuthenticationProvider
的责任是履行先前的步骤。我说的对吗?
我想要的是:令牌生成器使用OAuthAuthorizationServer,而令牌使用者使用OAuthBearerAuthentication(对访问令牌进行身份验证)。使用OWIN管道来管理所有东西,令牌东西和...
您知道,UseOAuthAuthorizationServer负责验证用户的工作。然后,UseOAuthBearerAuthentication的任务是确保只有经过身份验证的用户才能访问您的应用程序。通常,这两个作业分配给不同的Web应用程序。看来您的应用程序同时在做。