[英]ASP.NET 5 using openidconnect
我很困惑使用哪个软件包:
如何重定向到外部提供商? 我已经向控制器操作和app.UseCookieAuthentication();app.UseOpenIdConnectAuthentication();
添加了[Authorize]
app.UseCookieAuthentication();app.UseOpenIdConnectAuthentication();
到Startup.cs
。当我点击标有[Authorized]
属性的控制器操作时,发生错误401,但没有重定向。 要重定向,我需要使用Response.Challenge(new AuthenticationProperties() { RedirectUri = "/" },OpenIdConnectAuthenticationDefaults.AuthenticationScheme);
进行手动重定向Response.Challenge(new AuthenticationProperties() { RedirectUri = "/" },OpenIdConnectAuthenticationDefaults.AuthenticationScheme);
那我在做什么错呢?
Microsoft.AspNet.Security
重命名为Microsoft.AspNet.Authentication
,因此您应该使用Microsoft.AspNet.Authentication.OpenIdConnect "1.0.0-beta4"
。 在Startup.cs
使用此配置
app.UseOpenIdConnectAuthentication(options => { options.ClientId = "CientId"; options.Authority = "https://yourIdentityProviderUrl"; options.RedirectUri = "http://localhost:49181"; options.AuthenticationScheme = "Cookies"; options.SignInScheme = "Cookies"; options.ResponseType = "code id_token token"; options.Scope = "openid profile roles read write "; });
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.