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

View File

@ -20,7 +20,7 @@ func OpenIDConfigurationHandler() gin.HandlerFunc {
"token_endpoint": issuer + "/token", "token_endpoint": issuer + "/token",
"userinfo_endpoint": issuer + "/userinfo", "userinfo_endpoint": issuer + "/userinfo",
"jwks_uri": issuer + "/.well-known/jwks.json", "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"}, "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"}, "response_modes_supported": []string{"query", "fragment", "form_post", "web_message"},
"id_token_signing_alg_values_supported": []string{jwtType}, "id_token_signing_alg_values_supported": []string{jwtType},