fix: handle response

This commit is contained in:
Lakhan Samani 2022-10-16 22:16:37 +05:30
parent 3cd99fe5f6
commit 346c8e5a47
2 changed files with 44 additions and 23 deletions

View File

@ -137,30 +137,51 @@ func AuthorizeHandler() gin.HandlerFunc {
// in case, response type is code and user is already logged in send the code and state
// and cookie session will already be rolled over and set
if responseMode == constants.ResponseModeFormPost {
gc.HTML(http.StatusOK, authorizeFormPostTemplate, gin.H{
"target_origin": redirectURI,
"authorization_response": map[string]interface{}{
"type": "authorization_response",
"response": map[string]string{
"code": code,
"state": state,
},
},
})
} else {
gc.HTML(http.StatusOK, authorizeWebMessageTemplate, gin.H{
"target_origin": redirectURI,
"authorization_response": map[string]interface{}{
"type": "authorization_response",
"response": map[string]string{
"code": code,
"state": state,
},
},
})
// if responseMode == constants.ResponseModeFormPost {
// gc.HTML(http.StatusOK, authorizeFormPostTemplate, gin.H{
// "target_origin": redirectURI,
// "authorization_response": map[string]interface{}{
// "type": "authorization_response",
// "response": map[string]string{
// "code": code,
// "state": state,
// },
// },
// })
// } else {
// gc.HTML(http.StatusOK, authorizeWebMessageTemplate, gin.H{
// "target_origin": redirectURI,
// "authorization_response": map[string]interface{}{
// "type": "authorization_response",
// "response": map[string]string{
// "code": code,
// "state": state,
// },
// },
// })
// }
params := "code=" + code + "&state=" + state
if responseMode == constants.ResponseModeQuery {
if strings.Contains(redirectURI, "?") {
redirectURI = redirectURI + "&" + params
} else {
redirectURI = redirectURI + "?" + params
}
} else if responseMode == constants.ResponseModeFragment {
if strings.Contains(redirectURI, "#") {
redirectURI = redirectURI + "&" + params
} else {
redirectURI = redirectURI + "#" + params
}
}
handleResponse(gc, responseMode, loginURL, redirectURI, map[string]interface{}{
"code": code,
"state": state,
}, http.StatusOK)
return
}

View File

@ -20,7 +20,7 @@ func OpenIDConfigurationHandler() gin.HandlerFunc {
"token_endpoint": issuer + "/token",
"userinfo_endpoint": issuer + "/userinfo",
"jwks_uri": issuer + "/.well-known/jwks.json",
"response_types_supported": []string{"code", "token", "id_token", "code token", "code id_token", "token id_token", "code token id_token"},
"response_types_supported": []string{"code", "token", "id_token"},
"scopes_supported": []string{"openid", "email", "profile", "email_verified", "given_name", "family_name", "nick_name", "picture"},
"response_modes_supported": []string{"query", "fragment", "form_post", "web_message"},
"id_token_signing_alg_values_supported": []string{jwtType},