2016-11-10 1 views
0

現在、1つのサードサイドサービスに対してSSOを実装しています。このサービスはOIDCまたはOAuthをサポートしていないので、私はそれを独自に実装する必要があります。私が持っているものは、リクエストを処理するミドルウェアです。第三者のアプリケーションからのログイン要求としての要求を認識すると、それは承認リンクを作成し、承認エンドポイントである[identityserver]/connect/authorizeにリダイレクトします。それから、サーバーは私に処理するjwtトークンを返すべきです。とにかくアイデンティティサーバーは私にエラーを与え、ログファイルを調べるとfailureReason="STATUS_CODE"が見えます。しかし、Response.Redirect()ステータスコード302に設定してください。IdentityServer認証エンドポイント - > error = invalid_request failureReason = "STATUS_CODE"

クライアントが正しく設定されています。私は暗黙のフローを使用しています。しかし、AuthorizationCodeまたはClientCredentialsの場合は、次のメッセージとともにエラーページに送られます。クライアントアプリケーションが認識されていないか、認証されていません。ステータスコード204

ミドルウェアは、スニペット:

  string url = $"{context.Request.Scheme}://{context.Request.Host}"; 
      DiscoveryClient discoveryClient = new DiscoveryClient("https://localhost:44300/"); 
      DiscoveryResponse doc = await discoveryClient.GetAsync(); 

      AuthorizeRequest authorizeRequest = new AuthorizeRequest(doc.AuthorizeEndpoint); 
      string authorizeUrl = authorizeRequest.CreateAuthorizeUrl(
       clientId: "zendesk", 
       responseType: "id_token token", 
       scope: "openid email profile", 
       redirectUri: $"{url}/zendesk/authenticated", 
       state: Base64Url.Encode(returnTo.ToBytes())); 

      context.Response.Redirect(authorizeUrl); 

      return; 

リダイレクトリンク:

https://localhost:44300/connect/authorize?client_id=zendesk&response_type=id_token+token&scope=openid+email+profile&redirect_uri=https%3A%2F%2Flocalhost%3A44327%2Fzendesk%2Fauthenticated&state=[64encodedValue]

結果リンク

:任意のヒントの

https://localhost:44327/zendesk/authenticated#error=invalid_request&state=[64encodedValue]

おかげで、私は午前ここで死んだ

答えて

0

私は有用なメッセージが含まれて別のログました:

Nonce required for implicit and hybrid flow with openid scope 
{ 
... 
, 
"SubjectId": "unknown", 
"ResponseType": "id_token token", 
"ResponseMode": "form_post", 
"Flow": "Implicit", 
"RequestedScopes": "openid email profile", 
"State": "...", 
"Raw": { 
"client_id": "...", 
"response_type": "id_token token", 
"scope": "openid email profile", 
"redirect_uri": "...", 
"state": "...", 
"response_mode": "form_post" 
} 

をそして私はとにかく他のフローを使用することにしました。

0

/authorize要求にnonceパラメータを追加します。

OpenId Connect Standardはオプションですが、IdentityServer3はそれを必須パラメータとして持っています。 -

関連する問題