2016-08-29 2 views
1

을 사용하여 IOS 클라이언트 용 Identity Server 3을 설치하는 방법 최근 Thinktecture의 Identity Server 3 및 특히 클라이언트와 플로우를 가지고 놀았습니다. 이제 IOS 응용 프로그램Identity Server 3인증 코드 흐름을 사용하여 통신이 어떻게 이루어지는 지보고 싶습니다.인증 코드 흐름

ASP.NET Mvc 클라이언트 (하이브리드 플로우)와 AngularJS 클라이언트 (암시 적 플로우)가 STS (Identity Server 3)를 사용하고 있습니다.

new Client 
      { 
       ClientId = "implicitangularclient", 
       ClientName = "Angular client (Implicit)", 
       Flow = Flows.Implicit, 
       AllowAccessToAllScopes = true, 

       IdentityTokenLifetime = 10, 
       AccessTokenLifetime = 120, 
       // If we want to have SSO between Angular app and MVC app we need to have this option set to 
       // false for both the flows they implement(hybrid and implicit). 
       RequireConsent = false, 

       // redirect = URI of the Angular application 
       RedirectUris = new List<string> 
       { 
        "https://localhost:44555/callback.html", 
        // for silent refresh 
        "https://localhost:44555/silentrefreshframe.html" 
       }, 
       PostLogoutRedirectUris = new List<string>() 
       { 
        "https://localhost:44555/index.html" 
       } 
      } 

STS에 하이브리드 흐름 클라이언트 설치가 :

이 이

자, 이제 내 목표는이다

new Client 
      { 
       ClientId = "hybridclient", 
       ClientName = "Mvc client (Hybrid)", 
       Flow = Flows.Hybrid, 
       AllowAccessToAllScopes = true, 
       // If we want to have SSO between Angular app and MVC app we need to have this option set to 
       // false for both the flows they implement(hybrid and implicit). 
       RequireConsent = false, 

       IdentityTokenLifetime = 10, 
       AccessTokenLifetime = 120, 

       // redirect = URI of the MVC application 
       RedirectUris = new List<string> 
       { 
        "https://localhost:44556" 
       }, 

       // Needed when requesting refresh tokens 
       ClientSecrets = new List<Secret>() 
       { 
        new Secret("hybridflowsecret".Sha256()) 
       }, 
       PostLogoutRedirectUris = new List<string>() 
       { 
        "https://localhost:44556" 
       } 
      } 
STS에

암시 적 흐름 클라이언트 설치 다음 STS 측면은 다음과 같습니다 인증 코드 흐름을 사용하여 기본 IOS 응용 프로그램 인 클라이언트를 설정합니다. 나는 현재 IOS 애플리케이션이 없지만, 나는 그런 클라이언트를위한 설정을 할 수 있었으면 좋겠다. 그래서 어느 날 IOS 애플리케이션이있다면, 나는 이미 정의한 클라이언트 ID와 클라이언트 이름 만주고 실행할 수있다. 나는 인터넷에서 예제를 찾으려고 노력했지만 성공하지 못해서 파고 들기 시작했다. 지금 내가 궁금해하는 것은 반환 URL이 무엇이어야하고 처리 된 클라이언트 쪽을 얻는 방법입니다. 이 사양 다음 : oauth2-native-apps-03, 시작은 section 5입니다. 사용자 정의 URI 체계, 앱 주장 HTTPS URI 체계 및 루프백 리디렉션 : 그것은

는 세 가지 기본 애플 리케이션을위한 URI를 리다이렉션 방법이 있다고 말한다. 일반적으로

지금까지 너무 좋아하지만, 지금까지 내가 이해, 클라이언트 측 응용 프로그램에 우리가 레지스터 정의 내가 전에 해본 적이 없다 URI 방식 (에 내가 해본 적이 필요 IOS 개발). 또한 특정 URL (대부분 ReturnUris url)이 승인 프로세스를 시작한 전화 브라우저로 전달 된 후에 앱을 열어야합니다. 나는 또한 Inter App communication for IOS에 약간의 시간을 보냈지 만 내 질문에 대한 답변을 얻지 못했습니다 : IOS 응용 프로그램과 설정에서 자신을 추상화하고 STS 만 구성하려면 어떻게 할 수 있습니까? STS 수준에서이 경우 Client 개체를 설정하는 조건은 무엇입니까? 리다이렉트 URI가 무엇이되어야 하는가? (내가 아는 한 그것은 역 DNS 표기법의 일종이다. com.mycompany.apples와 같은 것)? 그냥 STS 관리자와 실제 클라이언트가 내게 와서 말하길 상상해보십시오 : 이봐, 난이 ID와,이 비밀과 반환 URI를 IOS 응용 프로그램을 가지고 귀하의 STS에 나를 위해 그것을 설정하십시오.

+1

모든 솔루션? –

답변

1

여기에 Xamarin 프로젝트 iOS Client example은 다음 라이브러리를 사용하고 있습니다.

  • IdentityModel 2.5.1
  • IdentityModel.OidcClient 2.0.0
    • 당신이 다음 ViewController.cs을 자 마린을 사용하려는 경우 것은 IdentityServer에 연결하는 로그인 코드가 있습니다.

       var options = new OidcClientOptions 
           { 
            Authority = "https://demo.identityserver.io", 
            ClientId = "native.hybrid", 
            Scope = "openid profile email api", 
            RedirectUri = "io.identitymodel.native://callback", 
      
            ResponseMode = OidcClientOptions.AuthorizeResponseMode.Redirect 
           }; 
      
           _client = new OidcClient (options); 
           _state = await _client.PrepareLoginAsync(); 
      
           AppDelegate.CallbackHandler = HandleCallback; 
           safari = new SafariServices.SFSafariViewController (new NSUrl (_state.StartUrl)); 
      
           this.PresentViewController (safari, true, null); 
      

      한 페이지 응용 프로그램 SPA를 사용하려는 경우는 그들이 가지고있는 문서 here 자신의 OIDC-client.js 라이브러리를 사용하여 자신의 좋은 sample project.

      참고 : oidc-client.js 라이브러리와 함께 URL 스키마를 사용하여 운이 없었습니다. 이 라이브러리가 그 능력을 지원하는지 아직도 조사 중입니다.

      프로젝트에 Cordova를 사용할 계획이 있다면 테스트를 거친 소스가 여기에 있습니다. 참고 : 테스트 할 iOS 장치가없는 경우 실행할 수있는 몇 가지 테스트 문제가 있습니다. 이 문제가 발생하여 Intel XDX tool을 사용하여 테스트 할 수있었습니다.이 테스트를 통해 Cordova 프로젝트를 테스트 서버에 푸시하고 Intel App Preview 애플리케이션을 통해 모바일 장치에서 실행할 수 있습니다.