diff options
| author | Grant Limberg <[email protected]> | 2021-11-30 17:27:13 -0800 |
|---|---|---|
| committer | Grant Limberg <[email protected]> | 2021-11-30 17:27:13 -0800 |
| commit | a33d7c64fe1932707fda20e7b41d7e2351b3f388 (patch) | |
| tree | d92eeff879a1f2f31ecd80e0fb548852806a04e8 /controller/PostgreSQL.cpp | |
| parent | d15516f0ef5e2fd06a91a88144e7ca793e4da75b (diff) | |
more fixin
Diffstat (limited to 'controller/PostgreSQL.cpp')
| -rw-r--r-- | controller/PostgreSQL.cpp | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/controller/PostgreSQL.cpp b/controller/PostgreSQL.cpp index 14e21054..15d359f8 100644 --- a/controller/PostgreSQL.cpp +++ b/controller/PostgreSQL.cpp @@ -80,6 +80,28 @@ std::vector<std::string> split(std::string str, char delim){ return tokens; } +std::string url_encode(const std::string &value) { + std::ostringstream escaped; + escaped.fill('0'); + escaped << std::hex; + + for (std::string::const_iterator i = value.begin(), n = value.end(); i != n; ++i) { + std::string::value_type c = (*i); + + // Keep alphanumeric and other accepted characters intact + if (isalnum(c) || c == '-' || c == '_' || c == '.' || c == '~') { + escaped << c; + continue; + } + + // Any other characters are percent-encoded + escaped << std::uppercase; + escaped << '%' << std::setw(2) << int((unsigned char) c); + escaped << std::nouppercase; + } + + return escaped.str(); +} } // anonymous namespace @@ -425,7 +447,7 @@ AuthInfo PostgreSQL::getSSOAuthInfo(const nlohmann::json &member, const std::str OSUtils::ztsnprintf(url, sizeof(authenticationURL), "%s?response_type=id_token&response_mode=form_post&scope=openid+email+profile&redirect_uri=%s&nonce=%s&state=%s&client_id=%s", authorization_endpoint.c_str(), - redirectURL.c_str(), + url_encode(redirectURL).c_str(), nonce.c_str(), state_hex, client_id.c_str()); @@ -436,6 +458,14 @@ AuthInfo PostgreSQL::getSSOAuthInfo(const nlohmann::json &member, const std::str info.ssoNonce = nonce; info.ssoState = std::string(state_hex); info.centralAuthURL = redirectURL; + fprintf( + stderr, + "ssoClientID: %s\nissuerURL: %s\nssoNonce: %s\nssoState: %s\ncentralAuthURL: %s", + info.ssoClientID.c_str(), + info.issuerURL.c_str(), + info.ssoNonce.c_str(), + info.ssoState.c_str(), + info.centralAuthURL.c_str()); } } else { fprintf(stderr, "client_id: %s\nauthorization_endpoint: %s\n", client_id.c_str(), authorization_endpoint.c_str()); |
