2016-11-10 21 views
0

我目前正在爲一項第三方服務實施SSO。該服務不支持OIDC或OAuth,所以我需要實現它的專有權。我擁有的是處理請求的中間件。當它從第三方應用程序重新確認請求爲登錄請求時,它會創建授權鏈接並將其重定向到作爲授權端點的[identityserver]/connect/authorize。然後服務器應該給我回jwt令牌,我會處理。無論如何身份服務器給我錯誤,當我看着日誌文件,我可以看到failureReason="STATUS_CODE"。但是Response.Redirect()狀態碼302,這應該是好的,不應該?IdentityServer身份驗證端點 - >錯誤= 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將它作爲必需參數。 -