asp.net-identity – UseOAuthBearerTokens vs UseOAuthBearerAut
发布时间:2020-07-20 16:21:10 所属栏目:asp.Net 来源:互联网
导读:在我们的启动类中,我已经配置了以下认证服务器选项: OAuthAuthorizationServerOptions OAuthServerOptions = new OAuthAuthorizationServerOptions(){ AllowInsecureHttp = true, TokenEndpointPath = new PathString(/api/v1/tok
在我们的启动类中,我已经配置了以下认证服务器选项: OAuthAuthorizationServerOptions OAuthServerOptions = new OAuthAuthorizationServerOptions() { AllowInsecureHttp = true,TokenEndpointPath = new PathString("/api/v1/token"),AccessTokenExpireTimeSpan = TimeSpan.FromDays(1),Provider = new SimpleAuthorizationServerProvider() }; 在这之后,我们应该使用哪个选项来实际启用承载认证?互联网上似乎有两种变化。 选项1: app.USEOAuthAuthorizationServer(OAuthServerOptions); app.USEOAuthBearerAuthentication(new OAuthBearerAuthenticationOptions()); 选项2: app.USEOAuthBearerTokens(OAuthServerOptions); 我已经测试过他们,两个结果是一样的。 这些选项之间有什么区别?我们什么时候应该使用? 解决方法USEOAuthBearerTokens扩展方法创建令牌服务器和中间件,以验证同一应用程序中的请求的令牌。使用反射器从源代码: USEOAuthAuthorizationServer(); // authorization server middleware USEOAuthBearerAuthentication(ApplicationOAuthBearerProvider); // application bearer token middleware USEOAuthBearerAuthentication(ExternalOAuthBearerProvider); // external bearer token middleware (编辑:鲜蔬坊站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |