Lia*_*iam 11 owin asp.net-mvc-5 openid-connect identityserver4
我有一个在ASP.NET MVC 4.5.2上运行的网站.我有一台IdentityServer4服务器正在运行但是当我尝试对它进行身份验证时,我得到一个:
invalid_request
Run Code Online (Sandbox Code Playgroud)
对于ASP.NET Core MVC,文档包含:
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationScheme = "Cookies"
});
app.UseOpenIdConnectAuthentication(new OpenIdConnectOptions
{
AuthenticationScheme = "oidc",
SignInScheme = "Cookies",
Authority = "http://localhost:5000",
RequireHttpsMetadata = false,
ClientId = "mvc",
SaveTokens = true
});
Run Code Online (Sandbox Code Playgroud)
我在我的项目Microsoft.Owin.Security.OpenIdConnect中包含以下NuGet包.我的代码如下:
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = "Cookies"
});
app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions
{
AuthenticationType = "oidc",
SignInAsAuthenticationType = "Cookies",
Authority = "http://localhost:5000",
ClientId = "mvc",
});
Run Code Online (Sandbox Code Playgroud)
如何正确连接到它?
好的,我有这个工作.
您需要将以下NuGet包添加到您的解决方案Microsoft.Owin.Security.OpenIdConnect.
我的Startup.Auth.cs包含
public void ConfigureAuth(IAppBuilder app)
{
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = "Cookies"
});
app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions
{
Authority = "http://localhost:5000", //ID Server
ClientId = "demo",
ResponseType = "id_token code",
SignInAsAuthenticationType = "Cookies",
RedirectUri = "http://localhost:51048/signin-oidc", //URL of website
Scope = "openid",
});
}
Run Code Online (Sandbox Code Playgroud)
IdentityServer中的我的客户端配置是:
public static IEnumerable<Client> GetClients()
{
return new List<Client> {
new Client {
ClientId = "demo",
AllowedScopes = new List<string> { "openid"},
AllowedGrantTypes = GrantTypes.Hybrid,
RedirectUris = new List<string>{"http://localhost:51048/signin-oidc"},
}
};
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3079 次 |
| 最近记录: |