mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2024-12-18 20:47:53 +00:00
more fixin
This commit is contained in:
parent
d15516f0ef
commit
a33d7c64fe
@ -63,29 +63,6 @@ namespace ZeroTier {
|
||||
|
||||
namespace {
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
static json _renderRule(ZT_VirtualNetworkRule &rule)
|
||||
{
|
||||
char tmp[128];
|
||||
@ -503,7 +480,7 @@ EmbeddedNetworkController::~EmbeddedNetworkController()
|
||||
}
|
||||
|
||||
void EmbeddedNetworkController::setSSORedirectURL(const std::string &url) {
|
||||
_ssoRedirectURL = url_encode(url);
|
||||
_ssoRedirectURL = url;
|
||||
}
|
||||
|
||||
void EmbeddedNetworkController::init(const Identity &signingId,Sender *sender)
|
||||
@ -1494,6 +1471,9 @@ void EmbeddedNetworkController::_request(
|
||||
if (!info.centralAuthURL.empty()) {
|
||||
Utils::scopy(nc->centralAuthURL, sizeof(nc->centralAuthURL), info.centralAuthURL.c_str());
|
||||
}
|
||||
if (!info.issuerURL.empty()) {
|
||||
Utils::scopy(nc->issuerURL, sizeof(nc->issuerURL), info.issuerURL.c_str());
|
||||
}
|
||||
if (!info.ssoNonce.empty()) {
|
||||
Utils::scopy(nc->ssoNonce, sizeof(nc->ssoNonce), info.ssoNonce.c_str());
|
||||
}
|
||||
|
@ -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());
|
||||
|
@ -253,7 +253,7 @@ public:
|
||||
memcpy(&_config, nwc, sizeof(ZT_VirtualNetworkConfig));
|
||||
fprintf(stderr, "ssoEnabled: %s, ssoVersion: %d\n",
|
||||
_config.ssoEnabled ? "true" : "false", _config.ssoVersion);
|
||||
|
||||
|
||||
if (_config.ssoEnabled && _config.ssoVersion == 1) {
|
||||
fprintf(stderr, "ssoEnabled for %s\n", nwid);
|
||||
if (_idc == nullptr)
|
||||
@ -261,6 +261,11 @@ public:
|
||||
assert(_config.issuerURL != nullptr);
|
||||
assert(_config.ssoClientID != nullptr);
|
||||
assert(_config.centralAuthURL != nullptr);
|
||||
|
||||
fprintf(stderr, "Issuer URL: %s\n", _config.issuerURL);
|
||||
fprintf(stderr, "Client ID: %s\n", _config.ssoClientID);
|
||||
fprintf(stderr, "Central Auth URL: %s\n", _config.centralAuthURL);
|
||||
|
||||
char buf[17] = {};
|
||||
_idc = zeroidc::zeroidc_new(
|
||||
Utils::hex(_config.nwid, buf),
|
||||
|
Loading…
Reference in New Issue
Block a user