2017-01-17 2 views
1

기본 모바일 응용 프로그램 (xamarin)을 Identity Server에 연결하려고합니다. 나는 처음에 흐름을 암묵적으로 설정했고, 나는 그 흐름이 잘못되었다고 말했다. 따라서 인증 코드 흐름을 변경했습니다. 내 클라이언트 정의가Xamarin 클라이언트를 Identity Server4에 연결

new Client 
    { 
     ClientId = "Xamarin", 
     ClientName = "Xamarin Client", 
     AllowedGrantTypes = GrantTypes.Code, 
     AllowAccessTokensViaBrowser = true, 
     RedirectUris = { "http://xx.xx.xx.xx/signin-oidc" }, 
     PostLogoutRedirectUris = { "http://xx.xx.xx.xx/signin-oidc" }, 
     AllowedCorsOrigins = { "http://xx.xx.xx.xx" }, 
     AllowedScopes = 
      { 
       StandardScopes.OpenId.Name, 
       StandardScopes.Profile.Name, 
       "api1" 
      }, 
     RequireConsent = false 
     } 

처럼 그리고 내 자 마린 응용 프로그램에서 보이는 방법은 다음과

이며, 이것은 내가 신원 서버에 연결하는 방법입니다.

void LoginButton_Clicked(object sender, EventArgs e) 
    { 
     StartFlow("token", "api1"); 
    } 

    public void StartFlow(string responseType, string scope) 
    { 
     var authorizeRequest = 
      new AuthorizeRequest("http://xx.xx.xx.xx/connect/authorize"); 


     var dic = new Dictionary<string, string>(); 
     dic.Add("client_id", "Xamarin"); 
     dic.Add("response_type", responseType); 
     dic.Add("scope", scope); 
     dic.Add("redirect_uri", "http://xx.xx.xx.xx/signin-oidc"); 
     dic.Add("nonce", Guid.NewGuid().ToString("N")); 


     _currentCSRFToken = Guid.NewGuid().ToString("N"); 
     dic.Add("state", _currentCSRFToken); 

     var authorizeUri = authorizeRequest.Create(dic); 
     webLogin.Source = authorizeUri; 
     webLogin.IsVisible = true; 
    } 

나는 모바일 앱의 오류 "unauthorized_client"GET 및 서버 내 로그 보여줍니다 :

fail: IdentityServer4.Validation.AuthorizeRequestValidator[0] 
    Invalid grant type for client: implicit 
    { 
    "ClientId": "Xamarin", 
    "ClientName": "Xamarin Client", 
    "RedirectUri": "http://xx.xx.xx.xx/signin-oidc", 
    "AllowedRedirectUris": [ 
     "http://xx.xx.xx.xx/signin-oidc" 
    ], 
    "SubjectId": "anonymous", 
    "ResponseType": "token", 
    "ResponseMode": "fragment", 
    "GrantType": "implicit", 
    "RequestedScopes": "", 
    "State": "5c53c5e5bbe44c0f8c5d4b401df0938e", 
    "Raw": { 
     "client_id": "Xamarin", 
     "response_type": "token", 
     "scope": "api1", 
     "redirect_uri": "http://xx.xx.xx.xx/signin-oidc", 
     "nonce": "49f21e8873d744bea76f6f00ebae3eb4", 
     "state": "5c53c5e5bbe44c0f8c5d4b401df0938e" 
    } 
    } 
    fail: IdentityServer4.Endpoints.AuthorizeEndpoint[0] 
    Request validation failed 
    info: IdentityServer4.Endpoints.AuthorizeEndpoint[0] 
    { 
    "ClientId": "Xamarin", 
    "ClientName": "Xamarin Client", 
    "RedirectUri": "http://xx.xx.xx.xx/signin-oidc", 
    "AllowedRedirectUris": [ 
     "http://xx.xx.xx.xx/signin-oidc" 
    ], 
    "SubjectId": "anonymous", 
    "ResponseType": "token", 
    "ResponseMode": "fragment", 
    "GrantType": "implicit", 
    "RequestedScopes": "", 
    "State": "5c53c5e5bbe44c0f8c5d4b401df0938e", 
    "Raw": { 
     "client_id": "Xamarin", 
     "response_type": "token", 
     "scope": "api1", 
     "redirect_uri": "http://xx.xx.xx.xx/signin-oidc", 
     "nonce": "49f21e8873d744bea76f6f00ebae3eb4", 
     "state": "5c53c5e5bbe44c0f8c5d4b401df0938e" 
    } 
    } 

하지만 당신이 내 코드를 확인 있을지에 대한 implict 흐름이없는 이 클라이언트 유형. 그리고 나는 그것이 authorization_code인지 확인하기 위해 데이터베이스를 두 번 점검했습니다. 누군가가 나를 고칠 수 있다면 고마워.

+0

오류가 난 클라이언트에서 보내는 responsetype에서입니다. 토큰은 암시 적, 코드는 권한 코드 흐름을 나타냅니다. 하지만 액세스 코드를 반환하지 않습니다 –

+0

https://leastprivilege.com/2016/01/17/which-openid-connectoauth-2-o-flow-is-the-right-one/ –

답변

2

그것은 idsrv4 순간에 response_type으로 code, code tokencode id_token token 지원하는 것처럼 보이지 않는다 - 단지 code id_token합니다. 테스트 클라이언트를 시도 할 때 현재의 데모 사이트와 클라이언트 server.code을 사용하여 /authorize 요청이 실패합니다.

내가 인증 코드에 관련된 발견

유일한 작업 클라이언트가 하이브리드 설정 (code id_token/server.hybrid)와 함께했다 :

https://demo.identityserver.io/connect/authorize? 
    client_id=server.hybrid& 
    response_type=code id_token& 
    response_mode=fragment& 
    redirect_uri=https://notused& 
    scope=openid api& 
    state=1& 
    nonce=2 

아니 그게 발견 문서에서 supported_response_types 목록에 이미 같은 이유 확인 . 어쩌면 도미닉/브록 입력 할 수 있습니다

"response_types_supported": [ 
    "code", 
    "token", 
    "id_token", 
    "id_token token", 
    "code id_token", 
    "code token", 
    "code id_token token" 
    ], 

비 작동 코드 흐름 인증 요청 (unsupported_response_type). 내가 알아 낸

https://demo.identityserver.io/connect/authorize? 
    client_id=server.code& 
    response_type=code& 
    response_mode=fragment& 
    redirect_uri=https://notused& 
    scope=openid api& 
    state=1& 
    nonce=2 
+0

이제 오류 메시지가 나타납니다. "client_id "이 누락되었거나 너무 오래되었습니다. 하지만 난 확실히 요청을 확인하고 그것에 client_id "xamarin"이 있습니다 –

+0

하이브리드 흐름과 클라이언트를 설정하려고하면 "코드 id_token"을 사용합니까? –

+0

Q2 : 범위 : "api2"가 ApiResources의 리소스로 존재합니까? –

관련 문제