2017-09-06 10 views
0

.net 1.1 핵심 코드에서 다음과 같이 인증을 수행하고 있습니다 (이는 베어러 토큰을 외부 URL로 보내고 리턴 토큰에서 클레임을 찾습니다). 이 코드는 Core 1.1에서 2.0으로 마이그레이션 - 인증

app.UseCookieAuthentication(new CookieAuthenticationOptions 
     { 
      AuthenticationScheme = "Cookies" 
     }); 

     app.UseOpenIdConnectAuthentication(new OpenIdConnectOptions 
     { 
      AuthenticationScheme = "oidc", 
      SignInScheme = "Cookies", 

      Authority = signinAuthority, 
      RequireHttpsMetadata = signinHTTPS, 

      ClientId = "skybus", 
      ClientSecret = "secret", 

      ResponseType = "code id_token", 
      Scope = { "api1", "offline_access" }, 

      GetClaimsFromUserInfoEndpoint = true, 
      SaveTokens = true 
     }); 

이 지금은 모두 UseCookieAuthentication & UseOpenIdConnectAuthentication이 변경을 코어 2.0 .NET으로 내 코드를 업그레이드 Configure 방법입니다. 나는 어려운 내가 위의 변경 후이 URL을 참조 브라우저에서 ConfigureServices 방법

services.AddAuthentication(options => { 
      options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme; 
      options.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme; 
     }) 
      .AddCookie() 
      .AddOpenIdConnect(o => 
      { 
       o.Authority = signinAuthority; 
       o.SignInScheme = "Cookies"; 
       o.RequireHttpsMetadata = signinHTTPS; 
       o.ClientId = "skybus"; 
       o.ClientSecret = "secret"; 
       o.ResponseType = "code id_token"; 
       o.GetClaimsFromUserInfoEndpoint = true; 
       o.SaveTokens = true; 
       o.Scope.Add("api1"); 
       o.Scope.Add("offline_access"); 
      }); 

에서 다음대로로 변경 무엇이 경우

에서 수행해야 할 것을 찾기 위해 찾는거야. 사용자가 로그인 또는

http://localhost:5000/Account/Login?ReturnUrl=%2F

답변

0

난 당신이 IdentityServer4를 사용하는 경우 모르는 내 웹 사이트의 홈 페이지로 돌아하지만이 제공하지 않은 경우 그것도 나에게 외부 로그인 페이지를 표시한다 ASP.NET Core 2.0 용 github의 일부 샘플.

희망이 도움이됩니다.

Sample Project