-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Ldapi unix socket support #24574
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Ldapi unix socket support #24574
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,6 +18,7 @@ | |
| * @author root <[email protected]> | ||
| * @author Victor Dubiniuk <[email protected]> | ||
| * @author Xuanwo <[email protected]> | ||
| * @author Vincent Van Houtte <[email protected]> | ||
| * | ||
| * @license AGPL-3.0 | ||
| * | ||
|
|
@@ -454,8 +455,14 @@ private function doCriticalValidation() { | |
| (string)$this->configPrefix .'): '; | ||
|
|
||
| //options that shall not be empty | ||
| $options = ['ldapHost', 'ldapPort', 'ldapUserDisplayName', | ||
| $options = ['ldapHost', 'ldapUserDisplayName', | ||
| 'ldapGroupDisplayName', 'ldapLoginFilter']; | ||
|
|
||
| //ldapPort should not be empty either unless ldapHost is pointing to a socket | ||
| if (!$this->configuration->usesLdapi()) { | ||
| $options[] = 'ldapPort'; | ||
| } | ||
|
|
||
| foreach ($options as $key) { | ||
| $val = $this->configuration->$key; | ||
| if (empty($val)) { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,6 +19,7 @@ | |
| * @author Tobias Perschon <[email protected]> | ||
| * @author Victor Dubiniuk <[email protected]> | ||
| * @author Xuanwo <[email protected]> | ||
| * @author Vincent Van Houtte <[email protected]> | ||
| * @author Côme Chilliet <[email protected]> | ||
| * | ||
| * @license AGPL-3.0 | ||
|
|
@@ -95,7 +96,10 @@ public function __destruct() { | |
| * @throws \Exception | ||
| */ | ||
| public function countEntries(string $filter, string $type): int { | ||
| $reqs = ['ldapHost', 'ldapPort', 'ldapBase']; | ||
| $reqs = ['ldapHost', 'ldapBase']; | ||
| if (!$this->configuration->usesLdapi()) { | ||
| $reqs[] = 'ldapPort'; | ||
| } | ||
| if ($type === 'users') { | ||
| $reqs[] = 'ldapUserFilter'; | ||
| } | ||
|
|
@@ -189,13 +193,13 @@ public function countInBaseDN(): WizardResult { | |
| * counts users with a specified attribute | ||
| * @return int|false | ||
| */ | ||
| public function countUsersWithAttribute(string $attr, bool $existsCheck = false) { | ||
| if (!$this->checkRequirements(['ldapHost', | ||
| 'ldapPort', | ||
| 'ldapBase', | ||
| 'ldapUserFilter', | ||
| ])) { | ||
| return false; | ||
| public function countUsersWithAttribute(string $attr, bool $existsCheck = false) { | ||
| $reqs = ['ldapHost', 'ldapBase', 'ldapUserFilter']; | ||
| if (!$this->configuration->usesLdapi()) { | ||
| $reqs[] = 'ldapPort'; | ||
| } | ||
| if (!$this->checkRequirements($reqs)) { | ||
| return false; | ||
| } | ||
|
|
||
| $filter = $this->access->combineFilterWithAnd([ | ||
|
|
@@ -215,11 +219,11 @@ public function countUsersWithAttribute(string $attr, bool $existsCheck = false) | |
| * @throws \Exception | ||
| */ | ||
| public function detectUserDisplayNameAttribute() { | ||
| if (!$this->checkRequirements(['ldapHost', | ||
| 'ldapPort', | ||
| 'ldapBase', | ||
| 'ldapUserFilter', | ||
| ])) { | ||
| $reqs = ['ldapHost', 'ldapBase', 'ldapUserFilter']; | ||
| if (!$this->configuration->usesLdapi()) { | ||
| $reqs[] = 'ldapPort'; | ||
| } | ||
| if (!$this->checkRequirements($reqs)) { | ||
| return false; | ||
| } | ||
|
|
||
|
|
@@ -257,11 +261,11 @@ public function detectUserDisplayNameAttribute() { | |
| * @return WizardResult|bool | ||
| */ | ||
| public function detectEmailAttribute() { | ||
| if (!$this->checkRequirements(['ldapHost', | ||
| 'ldapPort', | ||
| 'ldapBase', | ||
| 'ldapUserFilter', | ||
| ])) { | ||
| $reqs = ['ldapHost', 'ldapBase', 'ldapUserFilter']; | ||
| if (!$this->configuration->usesLdapi()) { | ||
| $reqs[] = 'ldapPort'; | ||
| } | ||
| if (!$this->checkRequirements($reqs)) { | ||
| return false; | ||
| } | ||
|
|
||
|
|
@@ -306,12 +310,12 @@ public function detectEmailAttribute() { | |
| * @throws \Exception | ||
| */ | ||
| public function determineAttributes() { | ||
| if (!$this->checkRequirements(['ldapHost', | ||
| 'ldapPort', | ||
| 'ldapBase', | ||
| 'ldapUserFilter', | ||
| ])) { | ||
| return false; | ||
| $reqs = ['ldapHost', 'ldapBase', 'ldapUserFilter']; | ||
| if (!$this->configuration->usesLdapi()) { | ||
| $reqs[] = 'ldapPort'; | ||
| } | ||
| if (!$this->checkRequirements($reqs)) { | ||
| return false; | ||
| } | ||
|
|
||
| $attributes = $this->getUserAttributes(); | ||
|
|
@@ -339,12 +343,12 @@ public function determineAttributes() { | |
| * @throws \Exception | ||
| */ | ||
| private function getUserAttributes() { | ||
| if (!$this->checkRequirements(['ldapHost', | ||
| 'ldapPort', | ||
| 'ldapBase', | ||
| 'ldapUserFilter', | ||
| ])) { | ||
| return false; | ||
| $reqs = ['ldapHost', 'ldapBase', 'ldapUserFilter']; | ||
| if (!$this->configuration->usesLdapi()) { | ||
| $reqs[] = 'ldapPort'; | ||
| } | ||
| if (!$this->checkRequirements($reqs)) { | ||
| return false; | ||
| } | ||
| $cr = $this->getConnection(); | ||
| if (!$cr) { | ||
|
|
@@ -395,12 +399,13 @@ public function determineGroupsForUsers() { | |
| * @return WizardResult|false the instance's WizardResult instance | ||
| * @throws \Exception | ||
| */ | ||
| private function determineGroups(string $dbKey, string $confKey, bool $testMemberOf = true) { | ||
| if (!$this->checkRequirements(['ldapHost', | ||
| 'ldapPort', | ||
| 'ldapBase', | ||
| ])) { | ||
| return false; | ||
| private function determineGroups(string $dbKey, string $confKey, bool $testMemberOf = true) { | ||
| $reqs = ['ldapHost', 'ldapBase']; | ||
| if (!$this->configuration->usesLdapi()) { | ||
| $reqs[] = 'ldapPort'; | ||
| } | ||
| if (!$this->checkRequirements($reqs)) { | ||
| return false; | ||
| } | ||
| $cr = $this->getConnection(); | ||
| if (!$cr) { | ||
|
|
@@ -476,11 +481,12 @@ public function fetchGroups(string $dbKey, string $confKey): array { | |
| * @return WizardResult|false | ||
| */ | ||
| public function determineGroupMemberAssoc() { | ||
| if (!$this->checkRequirements(['ldapHost', | ||
| 'ldapPort', | ||
| 'ldapGroupFilter', | ||
| ])) { | ||
| return false; | ||
| $reqs = ['ldapHost', 'ldapGroupFilter']; | ||
| if (!$this->configuration->usesLdapi()) { | ||
| $reqs[] = 'ldapPort'; | ||
| } | ||
| if (!$this->checkRequirements($reqs)) { | ||
| return false; | ||
| } | ||
| $attribute = $this->detectGroupMemberAssoc(); | ||
| if ($attribute === false) { | ||
|
|
@@ -498,10 +504,11 @@ public function determineGroupMemberAssoc() { | |
| * @throws \Exception | ||
| */ | ||
| public function determineGroupObjectClasses() { | ||
| if (!$this->checkRequirements(['ldapHost', | ||
| 'ldapPort', | ||
| 'ldapBase', | ||
| ])) { | ||
| $reqs = ['ldapHost', 'ldapBase']; | ||
| if (!$this->configuration->usesLdapi()) { | ||
| $reqs[] = 'ldapPort'; | ||
| } | ||
| if (!$this->checkRequirements($reqs)) { | ||
| return false; | ||
| } | ||
| $cr = $this->getConnection(); | ||
|
|
@@ -525,11 +532,12 @@ public function determineGroupObjectClasses() { | |
| * @throws \Exception | ||
| */ | ||
| public function determineUserObjectClasses() { | ||
| if (!$this->checkRequirements(['ldapHost', | ||
| 'ldapPort', | ||
| 'ldapBase', | ||
| ])) { | ||
| return false; | ||
| $reqs = ['ldapHost', 'ldapBase']; | ||
| if (!$this->configuration->usesLdapi()) { | ||
| $reqs[] = 'ldapPort'; | ||
| } | ||
| if (!$this->checkRequirements($reqs)) { | ||
| return false; | ||
| } | ||
| $cr = $this->getConnection(); | ||
| if (!$cr) { | ||
|
|
@@ -555,10 +563,11 @@ public function determineUserObjectClasses() { | |
| * @throws \Exception | ||
| */ | ||
| public function getGroupFilter() { | ||
| if (!$this->checkRequirements(['ldapHost', | ||
| 'ldapPort', | ||
| 'ldapBase', | ||
| ])) { | ||
| $reqs = ['ldapHost', 'ldapBase']; | ||
| if (!$this->configuration->usesLdapi()) { | ||
| $reqs[] = 'ldapPort'; | ||
| } | ||
| if (!$this->checkRequirements($reqs)) { | ||
| return false; | ||
| } | ||
| //make sure the use display name is set | ||
|
|
@@ -579,10 +588,11 @@ public function getGroupFilter() { | |
| * @throws \Exception | ||
| */ | ||
| public function getUserListFilter() { | ||
| if (!$this->checkRequirements(['ldapHost', | ||
| 'ldapPort', | ||
| 'ldapBase', | ||
| ])) { | ||
| $reqs = ['ldapHost', 'ldapBase']; | ||
| if (!$this->configuration->usesLdapi()) { | ||
| $reqs[] = 'ldapPort'; | ||
| } | ||
| if (!$this->checkRequirements($reqs)) { | ||
| return false; | ||
| } | ||
| //make sure the use display name is set | ||
|
|
@@ -605,11 +615,11 @@ public function getUserListFilter() { | |
| * @throws \Exception | ||
| */ | ||
| public function getUserLoginFilter() { | ||
| if (!$this->checkRequirements(['ldapHost', | ||
| 'ldapPort', | ||
| 'ldapBase', | ||
| 'ldapUserFilter', | ||
| ])) { | ||
| $reqs = ['ldapHost', 'ldapBase', 'ldapUserFilter']; | ||
| if (!$this->configuration->usesLdapi()) { | ||
| $reqs[] = 'ldapPort'; | ||
| } | ||
| if (!$this->checkRequirements($reqs)) { | ||
| return false; | ||
| } | ||
|
|
||
|
|
@@ -626,12 +636,12 @@ public function getUserLoginFilter() { | |
| * @return WizardResult|false | ||
| * @throws \Exception | ||
| */ | ||
| public function testLoginName(string $loginName) { | ||
| if (!$this->checkRequirements(['ldapHost', | ||
| 'ldapPort', | ||
| 'ldapBase', | ||
| 'ldapLoginFilter', | ||
| ])) { | ||
| public function testLoginName(string $loginName) { | ||
| $reqs = ['ldapHost', 'ldapBase', 'ldapUserFilter']; | ||
| if (!$this->configuration->usesLdapi()) { | ||
| $reqs[] = 'ldapPort'; | ||
| } | ||
| if (!$this->checkRequirements($reqs)) { | ||
| return false; | ||
| } | ||
|
|
||
|
|
@@ -717,9 +727,11 @@ public function guessPortAndTLS() { | |
| * @return WizardResult|false WizardResult on success, false otherwise | ||
| */ | ||
| public function guessBaseDN() { | ||
| if (!$this->checkRequirements(['ldapHost', | ||
| 'ldapPort', | ||
| ])) { | ||
| $reqs = ['ldapHost']; | ||
| if (!$this->configuration->usesLdapi()) { | ||
| $reqs[] = 'ldapPort'; | ||
| } | ||
| if (!$this->checkRequirements($reqs)) { | ||
| return false; | ||
| } | ||
|
|
||
|
|
@@ -1361,6 +1373,8 @@ private function getPortSettingsToTry(): array { | |
| $portSettings[] = ['port' => $port, 'tls' => true]; | ||
| } | ||
| $portSettings[] = ['port' => $port, 'tls' => false]; | ||
| } elseif ($this->configuration->usesLdapi()) { | ||
| $portSettings[] = ['port' => '', 'tls' => false]; | ||
come-nc marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| //default ports | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.