mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-04-21 22:46:54 +02:00
Let's just move this whole sso check up to make code flow a bit easier to reason about
This commit is contained in:
parent
326f7f7254
commit
fbeae3c468
1 changed files with 26 additions and 30 deletions
|
@ -1781,10 +1781,32 @@ void EmbeddedNetworkController::_startThreads()
|
|||
if (qe) {
|
||||
try {
|
||||
_request(qe->nwid,qe->fromAddr,qe->requestPacketId,qe->identity,qe->metaData);
|
||||
if (!_db.get(qe->nwid, network, qe->identity.address().toInt(), member)) {
|
||||
delete qe;
|
||||
qe = nullptr;
|
||||
continue;
|
||||
if (_db.get(qe->nwid, network, qe->identity.address().toInt(), member)) {
|
||||
bool networkSSOEnabled = OSUtils::jsonBool(network["ssoEnabled"], false);
|
||||
if (networkSSOEnabled) {
|
||||
int64_t now = OSUtils::now();
|
||||
{
|
||||
std::lock_guard<std::mutex> l(_expiringSoon_l);
|
||||
for(auto s=_expiringSoon.begin();s!=_expiringSoon.end();) {
|
||||
Metrics::sso_expiration_checks++;
|
||||
const int64_t when = s->first;
|
||||
if (when <= now) {
|
||||
int64_t authenticationExpiryTime = (int64_t)OSUtils::jsonInt(member["authenticationExpiryTime"], 0);
|
||||
if (authenticationExpiryTime <= now) {
|
||||
expired.push_back(s->second);
|
||||
}
|
||||
s = _expiringSoon.erase(s);
|
||||
} else {
|
||||
// Don't bother going further into the future than necessary.
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
for(auto e=expired.begin();e!=expired.end();++e) {
|
||||
Metrics::sso_member_deauth++;
|
||||
onNetworkMemberDeauthorize(nullptr, e->networkId, e->nodeId);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (std::exception &e) {
|
||||
fprintf(stderr,"ERROR: exception in controller request handling thread: %s" ZT_EOL_S,e.what());
|
||||
|
@ -1795,32 +1817,6 @@ void EmbeddedNetworkController::_startThreads()
|
|||
qe = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
bool networkSSOEnabled = OSUtils::jsonBool(network["ssoEnabled"], false);
|
||||
if (networkSSOEnabled) {
|
||||
int64_t now = OSUtils::now();
|
||||
{
|
||||
std::lock_guard<std::mutex> l(_expiringSoon_l);
|
||||
for(auto s=_expiringSoon.begin();s!=_expiringSoon.end();) {
|
||||
Metrics::sso_expiration_checks++;
|
||||
const int64_t when = s->first;
|
||||
if (when <= now) {
|
||||
int64_t authenticationExpiryTime = (int64_t)OSUtils::jsonInt(member["authenticationExpiryTime"], 0);
|
||||
if (authenticationExpiryTime <= now) {
|
||||
expired.push_back(s->second);
|
||||
}
|
||||
s = _expiringSoon.erase(s);
|
||||
} else {
|
||||
// Don't bother going further into the future than necessary.
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
for(auto e=expired.begin();e!=expired.end();++e) {
|
||||
Metrics::sso_member_deauth++;
|
||||
onNetworkMemberDeauthorize(nullptr, e->networkId, e->nodeId);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue