mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-06 20:43:44 +02:00
Merge branch 'dev' into central-controller
This commit is contained in:
commit
f80103778a
1 changed files with 37 additions and 21 deletions
|
@ -386,6 +386,14 @@ AuthInfo PostgreSQL::getSSOAuthInfo(const nlohmann::json &member, const std::str
|
||||||
// check if the member exists first.
|
// check if the member exists first.
|
||||||
pqxx::row count = w.exec_params1("SELECT count(id) FROM ztc_member WHERE id = $1 AND network_id = $2 AND deleted = false", memberId, networkId);
|
pqxx::row count = w.exec_params1("SELECT count(id) FROM ztc_member WHERE id = $1 AND network_id = $2 AND deleted = false", memberId, networkId);
|
||||||
if (count[0].as<int>() == 1) {
|
if (count[0].as<int>() == 1) {
|
||||||
|
// get active nonce, if exists.
|
||||||
|
pqxx::result r = w.exec_params("SELECT nonce FROM ztc_sso_expiry "
|
||||||
|
"WHERE network_id = $1 AND member_id = $2 "
|
||||||
|
"AND ((NOW() AT TIME ZONE 'UTC') <= authentication_expiry_time) AND ((NOW() AT TIME ZONE 'UTC') <= nonce_expiration)",
|
||||||
|
networkId, memberId);
|
||||||
|
|
||||||
|
if (r.size() == 0) {
|
||||||
|
// no active nonce.
|
||||||
// find an unused nonce, if one exists.
|
// find an unused nonce, if one exists.
|
||||||
pqxx::result r = w.exec_params("SELECT nonce FROM ztc_sso_expiry "
|
pqxx::result r = w.exec_params("SELECT nonce FROM ztc_sso_expiry "
|
||||||
"WHERE network_id = $1 AND member_id = $2 "
|
"WHERE network_id = $1 AND member_id = $2 "
|
||||||
|
@ -414,6 +422,14 @@ AuthInfo PostgreSQL::getSSOAuthInfo(const nlohmann::json &member, const std::str
|
||||||
fprintf(stderr, "> 1 unused nonce!\n");
|
fprintf(stderr, "> 1 unused nonce!\n");
|
||||||
exit(6);
|
exit(6);
|
||||||
}
|
}
|
||||||
|
} else if (r.size() == 1) {
|
||||||
|
nonce = r.at(0)[0].as<std::string>();
|
||||||
|
Utils::unhex(nonce.c_str(), nonceBytes, sizeof(nonceBytes));
|
||||||
|
} else {
|
||||||
|
// more than 1 nonce in use? Uhhh...
|
||||||
|
fprintf(stderr, "> 1 nonce in use for network member?!?\n");
|
||||||
|
exit(7);
|
||||||
|
}
|
||||||
|
|
||||||
r = w.exec_params("SELECT org.client_id, org.authorization_endpoint, org.issuer, org.sso_impl_version "
|
r = w.exec_params("SELECT org.client_id, org.authorization_endpoint, org.issuer, org.sso_impl_version "
|
||||||
"FROM ztc_network AS nw, ztc_org AS org "
|
"FROM ztc_network AS nw, ztc_org AS org "
|
||||||
|
|
Loading…
Add table
Reference in a new issue