【发布时间】:2016-04-24 18:37:22
【问题描述】:
我在 asp.net v5 环境中运行 IdentityServer3。我正在尝试将 OWIN OpenID Connect 模块连接为身份提供者,以便用户可以使用本地凭据或联合出 Azure AD 实例的凭据通过 IDS3 登录。这是我的设置:
身份提供者配置:
public static void ConfigureIdentityProviders(IAppBuilder app, string signInAsType)
{
app.UseOpenIdConnectAuthentication(
new OpenIdConnectAuthenticationOptions
{
ClientId = "a-valid-client-id",
Authority = "https://login.microsoftonline.com/some-valid-authority",
PostLogoutRedirectUri = "https://localhost:44300/",
SignInAsAuthenticationType = OpenIdConnectAuthenticationDefaults.AuthenticationType,
CallbackPath = new PathString("/identity/callback"),
ResponseType = "code id_token token"
});
}
IDS3 配置:
app.Map("/identity", idsrvApp =>
{
idsrvApp.UseIdentityServer(new IdentityServerOptions()
{
SiteName = "Identity Server",
SigningCertificate = LoadCertificate(),
AuthenticationOptions = new AuthenticationOptions()
{
IdentityProviders = ConfigureIdentityProviders
},
Factory = new IdentityServerServiceFactory()
.UseInMemoryUsers(Users.Get())
.UseInMemoryClients(Clients.Get())
.UseInMemoryScopes(StandardScopes.All)
});
});
这部分工作正常,Azure 将令牌作为 POST 请求返回到指定的端点。我收到以下错误:
{"Message":"The requested resource does not support http method 'POST'."}
我尝试了各种不同的重定向 URL - 例如,重定向到“/”,重定向到“/identity”中的其他页面,但总是得到相同的错误。我不确定是否应该在回发 URL 上安装一些资源来显式处理令牌,但我的印象是 OWIN 应该为我处理这个?
我开始认为这可能是我在 ASP.net 5 中使用 OWIN 中间件引起的问题。
谢谢!
【问题讨论】:
-
我建议你看看ASOS。我目前正在使用它,并且对它有很好的体验。有一些示例可以帮助您启动和运行。
-
如果您只有一个 oidc ext 提供程序 - 您不需要设置回调路径 - 可以尝试不设置它以消除一种可能的错误来源
-
好的提示 - 将其关闭并进一步发展。谢谢!
标签: asp.net-mvc asp.net-core identityserver3