Skip to content

Commit

Permalink
[LDAP] Add flag to disable search nested groups (ydb-platform#8354)
Browse files Browse the repository at this point in the history
  • Loading branch information
molotkov-and authored Aug 28, 2024
1 parent ef61b81 commit d74e4a9
Show file tree
Hide file tree
Showing 3 changed files with 203 additions and 9 deletions.
5 changes: 5 additions & 0 deletions ydb/core/protos/auth.proto
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ message TLdapAuthentication {
optional TCertRequire CertRequire = 3 [default = DEMAND];
}

message TExtendedSettings {
optional bool EnableNestedGroupsSearch = 1 [default = false];
}

optional string Host = 1; // DEPRECATED: Use Hosts instead it
optional uint32 Port = 2;
optional string BaseDn = 3;
Expand All @@ -116,4 +120,5 @@ message TLdapAuthentication {
optional string RequestedGroupAttribute = 9;
repeated string Hosts = 10;
optional string Scheme = 11 [default = "ldap"];
optional TExtendedSettings ExtendedSettings = 12;
}
5 changes: 4 additions & 1 deletion ydb/core/security/ldap_auth_provider/ldap_auth_provider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ class TLdapAuthProvider : public NActors::TActorBootstrapped<TLdapAuthProvider>
NKikimrLdap::BerFree(ber, 0);
}
std::vector<TString> allUserGroups;
if (!directUserGroups.empty()) {
auto& extendedSettings = Settings.GetExtendedSettings();
if (extendedSettings.GetEnableNestedGroupsSearch() && !directUserGroups.empty()) {
// Active Directory has special matching rule to fetch nested groups in one request it is MatchingRuleInChain
// We don`t know what is ldap server. Is it Active Directory or OpenLdap or other server?
// If using MatchingRuleInChain return empty list of groups it means that ldap server isn`t Active Directory
Expand All @@ -159,6 +160,8 @@ class TLdapAuthProvider : public NActors::TActorBootstrapped<TLdapAuthProvider>
allUserGroups = std::move(directUserGroups);
GetNestedGroups(ld, &allUserGroups);
}
} else {
allUserGroups = std::move(directUserGroups);
}
NKikimrLdap::MsgFree(entry);
NKikimrLdap::Unbind(ld);
Expand Down
Loading

0 comments on commit d74e4a9

Please sign in to comment.