mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-06 20:43:44 +02:00
move this outside the auth block. If SSO is enabled, it should be checked whether authorized or not
This commit is contained in:
parent
bc901d613d
commit
287c19e822
1 changed files with 16 additions and 15 deletions
|
@ -1331,6 +1331,20 @@ void EmbeddedNetworkController::_request(
|
||||||
// Otherwise no, we use standard auth logic.
|
// Otherwise no, we use standard auth logic.
|
||||||
bool networkSSOEnabled = OSUtils::jsonBool(network["ssoEnabled"], false);
|
bool networkSSOEnabled = OSUtils::jsonBool(network["ssoEnabled"], false);
|
||||||
bool memberSSOExempt = OSUtils::jsonBool(member["ssoExempt"], false);
|
bool memberSSOExempt = OSUtils::jsonBool(member["ssoExempt"], false);
|
||||||
|
|
||||||
|
if (networkSSOEnabled && !memberSSOExempt) {
|
||||||
|
int64_t authenticationExpiryTime = (int64_t)OSUtils::jsonInt(member["authenticationExpiryTime"], 0);
|
||||||
|
if ((authenticationExpiryTime == 0) || (authenticationExpiryTime < now)) {
|
||||||
|
Dictionary<1024> authInfo;
|
||||||
|
std::string authenticationURL = _db.getSSOAuthURL(member);
|
||||||
|
if (!authenticationURL.empty()) {
|
||||||
|
authInfo.add("aU", authenticationURL.c_str());
|
||||||
|
}
|
||||||
|
_sender->ncSendError(nwid,requestPacketId,identity.address(),NetworkController::NC_ERROR_AUTHENTICATION_REQUIRED, authInfo.data(), authInfo.sizeBytes());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (authorized) {
|
if (authorized) {
|
||||||
// Update version info and meta-data if authorized and if this is a genuine request
|
// Update version info and meta-data if authorized and if this is a genuine request
|
||||||
if (requestPacketId) {
|
if (requestPacketId) {
|
||||||
|
@ -1356,21 +1370,8 @@ void EmbeddedNetworkController::_request(
|
||||||
ms.identity = identity;
|
ms.identity = identity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (networkSSOEnabled && !memberSSOExempt) {
|
|
||||||
int64_t authenticationExpiryTime = (int64_t)OSUtils::jsonInt(member["authenticationExpiryTime"], 0);
|
|
||||||
if ((authenticationExpiryTime == 0) || (authenticationExpiryTime < now)) {
|
|
||||||
Dictionary<1024> authInfo;
|
|
||||||
std::string authenticationURL = _db.getSSOAuthURL(member);
|
|
||||||
if (!authenticationURL.empty()) {
|
|
||||||
authInfo.add("aU", authenticationURL.c_str());
|
|
||||||
}
|
|
||||||
_sender->ncSendError(nwid,requestPacketId,identity.address(),NetworkController::NC_ERROR_AUTHENTICATION_REQUIRED, authInfo.data(), authInfo.sizeBytes());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// If they are not authorized, STOP!
|
// If they are not authorized, STOP!
|
||||||
DB::cleanMember(member);
|
DB::cleanMember(member);
|
||||||
_db.save(member,true);
|
_db.save(member,true);
|
||||||
|
|
Loading…
Add table
Reference in a new issue