mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-03-10 22:44:21 +00:00
more fixin
This commit is contained in:
parent
d15516f0ef
commit
a33d7c64fe
@ -63,29 +63,6 @@ namespace ZeroTier {
|
|||||||
|
|
||||||
namespace {
|
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)
|
static json _renderRule(ZT_VirtualNetworkRule &rule)
|
||||||
{
|
{
|
||||||
char tmp[128];
|
char tmp[128];
|
||||||
@ -503,7 +480,7 @@ EmbeddedNetworkController::~EmbeddedNetworkController()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void EmbeddedNetworkController::setSSORedirectURL(const std::string &url) {
|
void EmbeddedNetworkController::setSSORedirectURL(const std::string &url) {
|
||||||
_ssoRedirectURL = url_encode(url);
|
_ssoRedirectURL = url;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmbeddedNetworkController::init(const Identity &signingId,Sender *sender)
|
void EmbeddedNetworkController::init(const Identity &signingId,Sender *sender)
|
||||||
@ -1494,6 +1471,9 @@ void EmbeddedNetworkController::_request(
|
|||||||
if (!info.centralAuthURL.empty()) {
|
if (!info.centralAuthURL.empty()) {
|
||||||
Utils::scopy(nc->centralAuthURL, sizeof(nc->centralAuthURL), info.centralAuthURL.c_str());
|
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()) {
|
if (!info.ssoNonce.empty()) {
|
||||||
Utils::scopy(nc->ssoNonce, sizeof(nc->ssoNonce), info.ssoNonce.c_str());
|
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;
|
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
|
} // anonymous namespace
|
||||||
|
|
||||||
@ -425,7 +447,7 @@ AuthInfo PostgreSQL::getSSOAuthInfo(const nlohmann::json &member, const std::str
|
|||||||
OSUtils::ztsnprintf(url, sizeof(authenticationURL),
|
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",
|
"%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(),
|
authorization_endpoint.c_str(),
|
||||||
redirectURL.c_str(),
|
url_encode(redirectURL).c_str(),
|
||||||
nonce.c_str(),
|
nonce.c_str(),
|
||||||
state_hex,
|
state_hex,
|
||||||
client_id.c_str());
|
client_id.c_str());
|
||||||
@ -436,6 +458,14 @@ AuthInfo PostgreSQL::getSSOAuthInfo(const nlohmann::json &member, const std::str
|
|||||||
info.ssoNonce = nonce;
|
info.ssoNonce = nonce;
|
||||||
info.ssoState = std::string(state_hex);
|
info.ssoState = std::string(state_hex);
|
||||||
info.centralAuthURL = redirectURL;
|
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 {
|
} else {
|
||||||
fprintf(stderr, "client_id: %s\nauthorization_endpoint: %s\n", client_id.c_str(), authorization_endpoint.c_str());
|
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));
|
memcpy(&_config, nwc, sizeof(ZT_VirtualNetworkConfig));
|
||||||
fprintf(stderr, "ssoEnabled: %s, ssoVersion: %d\n",
|
fprintf(stderr, "ssoEnabled: %s, ssoVersion: %d\n",
|
||||||
_config.ssoEnabled ? "true" : "false", _config.ssoVersion);
|
_config.ssoEnabled ? "true" : "false", _config.ssoVersion);
|
||||||
|
|
||||||
if (_config.ssoEnabled && _config.ssoVersion == 1) {
|
if (_config.ssoEnabled && _config.ssoVersion == 1) {
|
||||||
fprintf(stderr, "ssoEnabled for %s\n", nwid);
|
fprintf(stderr, "ssoEnabled for %s\n", nwid);
|
||||||
if (_idc == nullptr)
|
if (_idc == nullptr)
|
||||||
@ -261,6 +261,11 @@ public:
|
|||||||
assert(_config.issuerURL != nullptr);
|
assert(_config.issuerURL != nullptr);
|
||||||
assert(_config.ssoClientID != nullptr);
|
assert(_config.ssoClientID != nullptr);
|
||||||
assert(_config.centralAuthURL != 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] = {};
|
char buf[17] = {};
|
||||||
_idc = zeroidc::zeroidc_new(
|
_idc = zeroidc::zeroidc_new(
|
||||||
Utils::hex(_config.nwid, buf),
|
Utils::hex(_config.nwid, buf),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user