Asp.net UseIdentityServerBearTokenAuthentication不适用于IdentityServer3
我已经使用了IdentityServer v3,现在我想要一个网站同时作为身份主机和web api主机 authority选项不用于验证令牌。我已经验证了令牌端点,并且令牌验证端点按预期工作(我可以使用postman获取并验证令牌)。我使用[Authorize]属性来修饰我的控制器方法。在IdentityServer上启用了完整日志记录,当发出标头名称为“Authorization”且值为“Bearer mytokenhere”的api请求时,不会记录任何内容 这是ASP.NET 5上使用Visual Studio 2015 CTP6的vNext网站Asp.net UseIdentityServerBearTokenAuthentication不适用于IdentityServer3,asp.net,owin,asp.net-core-mvc,identityserver3,Asp.net,Owin,Asp.net Core Mvc,Identityserver3,我已经使用了IdentityServer v3,现在我想要一个网站同时作为身份主机和web api主机 authority选项不用于验证令牌。我已经验证了令牌端点,并且令牌验证端点按预期工作(我可以使用postman获取并验证令牌)。我使用[Authorize]属性来修饰我的控制器方法。在IdentityServer上启用了完整日志记录,当发出标头名称为“Authorization”且值为“Bearer mytokenhere”的api请求时,不会记录任何内容 这是ASP.NET 5上使用Vis
app.UseMvc();
var certFile = AppDomain.CurrentDomain.BaseDirectory + "\\myawesomesite.pfx";
app.Map("/core", core =>
{
var factory = InMemoryFactory.Create(
users: Users.Get(),
clients: Clients.Get(),
scopes: Scopes.Get());
var idsrvOptions = new IdentityServerOptions
{
SiteName = "Lektieplan",
Factory = factory,
RequireSsl = false,
SigningCertificate = new X509Certificate2(certFile, "lektieplan"),
CorsPolicy = CorsPolicy.AllowAll,
LoggingOptions = new LoggingOptions { EnableWebApiDiagnostics = true,EnableHttpLogging = true, IncludeSensitiveDataInLogs = true, WebApiDiagnosticsIsVerbose = true }
};
core.UseIdentityServer(idsrvOptions);
});
app.UseIdentityServerBearerTokenAuthentication(new IdentityServerBearerTokenAuthenticationOptions
{
Authority = "http://localhost:57540/core",
RequiredScopes = new[] { "api1" },
});
还有我的project.json
我的依赖项:
"Microsoft.AspNet.Server.IIS": "1.0.0-beta3",
"Microsoft.AspNet.Mvc": "6.0.0-beta3",
"Microsoft.AspNet.StaticFiles": "1.0.0-beta3",
"Microsoft.AspNet.Server.WebListener": "1.0.0-beta3",
"Thinktecture.IdentityServer3": "1.3.0.0",
"Microsoft.AspNet.Owin": "1.0.0.0-beta3",
"Microsoft.AspNet.Security.DataProtection": "1.0.0.0-beta3",
"Thinktecture.IdentityServer3.AccessTokenValidation": "1.2.2",
"Autofac": "4.0.0-alpha1",
"log4net": "2.0.3"
在我看来,提供的一些示例之所以有效,是因为有一个基于cookie的选项。我不想使用cookies。UseIdentityServerBearerTokenAuthentication是您唯一的身份验证类型吗?您是否为MVC定义了任何过滤器 我会尝试将应用程序拆分为单独的katana管道,这样它们就不会发生冲突 伪:
app.Map("/core", a => a.UseIdsrv());
app.Map("/somethingweb", a => a.UseMvc());
app.Map("/api", a => {
a.UseBearerTokenAuth();
a.UseWebApi(); //or Mvc from now on, with v5
});
我猜您也需要将cookieauth添加到mvc管道中,这取决于您想要实现什么。我认为用于身份验证的owin中间件与/core owin中间件冲突,有什么提示如何调试吗?有什么消息吗?现在能用了吗?我也想这样做。