繁体   English   中英

使用openidconnect的ASP.NET 5

[英]ASP.NET 5 using openidconnect

  1. 我很困惑使用哪个软件包:

    • Microsoft.AspNet.Authentication.OpenIdConnect“ 1.0.0-beta4”
    • Microsoft.AspNet.Security.OpenIdConnect“ 1.0.0-beta3”
  2. 如何重定向到外部提供商? 我已经向控制器操作和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); 那我在做什么错呢?

  1. 他们将Microsoft.AspNet.Security重命名为Microsoft.AspNet.Authentication ,因此您应该使用Microsoft.AspNet.Authentication.OpenIdConnect "1.0.0-beta4"
  2. 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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM