2016-12-08 3 views
2

지난 한 해 동안 다중 응용 프로그램과 함께 IdentityServer3를 사용하고 있습니다. 이러한 모든 응용 프로그램은 .NET Framework 4.5에서 실행됩니다. 이제 ASP.Net Core MVC (1.1) 응용 프로그램을 만들었으므로이 응용 프로그램의 보안을 위해 IdentityServer를 사용하고 싶습니다. 그러나 나는 그것을 작동하게 고투하고있다. 401 Unauthorized 오류가 발생합니다.401 ASP.Net Core 1.1에서 IdentityServer3 인증을받지 않은 MVC 응용 프로그램

app.UseCookieAuthentication(new CookieAuthenticationOptions 
{ 
    AuthenticationScheme = "Cookies", 
    AutomaticAuthenticate = true, 
    AutomaticChallenge = true 
}); 

JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear(); 

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

    Authority = "<IdentityServer URL>", 
    RequireHttpsMetadata = false, 

    ClientId = "clientid", 

    ResponseType = "token id_token", 
    Scope = { "openid","email"}, 

    SaveTokens = true, 

    PostLogoutRedirectUri = "http://localhost:29995/", 

    Scope = { "openid, email" }, 
    ResponseType = "id_token token", 

    Events = new OpenIdConnectEvents() 
    { 
     OnTokenValidated = (context) => 
     { 
      //my code 
      return Task.FromResult(0); 
     } 
    } 
}); 

내가 무단 (401)를 얻고 보안 페이지를 공격하려고 : 여기

은 내가 사용하고있는 구성입니다. 그것도 IdentityServer의 로그인 페이지에 가지 않습니다. 이

https://<IdentityServerUrl>/connect/authorize?client_id=APITestweb&redirect_uri=http://localhost:29995/signin-oidc&response_type=code id_token&scope=openid profile email&response_mode=form_post&nonce=<data>&state=<data> 

클라이언트 ID를 맞추려고하고 URL을 제대로 구성

URL입니다. 다른 ASP.Net MVC 응용 프로그램 (ASP.Net 코어가 아닌)을 만들려고했는데 동일한 구성 정보로 올바르게 작동합니다.

도와주세요. (하나를 호출 할 수 있습니다로, 또는 변경을 깨는)

[편집] 당신이 Microsoft.AspNetCore.Authentication.OpenIdConnect v.1.1.0을 사용하는 경우 로그인 정보

[Debug] Executing action "WebClient.Controllers.HomeController.About (WebClient)" 
[Information] Authorization failed for user: null. 
[Warning] Authorization failed for the request at filter '"Microsoft.AspNetCore.Mvc.Authorization.AuthorizeFilter"'. 
[Information] Executing ChallengeResult with authentication schemes ([]). 
[Debug] AuthenticationScheme: "Cookies" was not authenticated. 
[Verbose] Entering "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectHandler"'s HandleUnauthorizedAsync. 
[Verbose] Using properties.RedirectUri for 'local redirect' post authentication: '"http://localhost:29995/Home/About"'. 
[Debug] Reading data from file '"C:\path\DataProtection-Keys\key-2a848b38-3cf4-4c57-b8ef-4c0b56c83993.xml"'. 
[Debug] Found key {2a848b38-3cf4-4c57-b8ef-4c0b56c83993}. 
[Debug] Considering key {2a848b38-3cf4-4c57-b8ef-4c0b56c83993} with expiration date 2017-03-08 21:08:54Z as default key. 
[Debug] Decrypting secret element using Windows DPAPI. 
[Debug] Opening CNG algorithm '"AES"' from provider 'null' with chaining mode CBC. 
[Debug] Opening CNG algorithm '"SHA256"' from provider 'null' with HMAC. 
[Debug] Using key {2a848b38-3cf4-4c57-b8ef-4c0b56c83993} as the default key. 
[Verbose] Performing protect operation to key {2a848b38-3cf4-4c57-b8ef-4c0b56c83993} with purposes "('project path', 'Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectMiddleware', 'System.String', 'oidc', 'v1')". 
[Verbose] Performing protect operation to key {2a848b38-3cf4-4c57-b8ef-4c0b56c83993} with purposes "('project path', 'Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectMiddleware', 'System.String', 'oidc', 'v1')". 
[Information] AuthenticationScheme: "oidc" was challenged. 
[Information] Request finished in 1301.6524ms 401 
[Debug] Connection id ""0HL10CR7G2G0J"" completed keep alive response. 
+0

1.1 프로젝트에 로깅을 추가 했습니까? 로깅은 무엇을 말합니까? – Lutando

+0

@ 루탄도 감사합니다. 질문에 로그 정보를 추가했습니다. – user3731783

+0

OIDC mw의 버전은 무엇입니까? –

답변

3

을 추가, 거기에 현재 버그입니다.

나를 위해 1.0.0 패키지가 계속 작동하므로 다운 그레이드가 도움이되는지 확인하십시오.

Link to GitHub issue on change introduced in 1.1.0 and why it was breaking

+0

당신이 자리하고 있습니다. 정말 고맙습니다. 유사한 문제가있는 다른 사람들에게만 Microsoft.AspNetCore.Authentication.Cookies를 다운 그레이드해야했습니다. 그 후 full.Net Framework에서 필요하지 않은 허용 된 리디렉션 URI에 singin-oidc 경로를 추가해야했습니다. – user3731783