Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>pull/44533/head
@@ -38,8 +38,76 @@ namespace OCA\User_LDAP; | |||
use Psr\Log\LoggerInterface; | |||
/** | |||
* @property int ldapPagingSize holds an integer | |||
* @property string ldapUserAvatarRule | |||
* @property string $ldapHost | |||
* @property string $ldapPort | |||
* @property string $ldapBackupHost | |||
* @property string $ldapBackupPort | |||
* @property string $ldapBackgroundHost | |||
* @property string $ldapBackgroundPort | |||
* @property array|'' $ldapBase | |||
* @property array|'' $ldapBaseUsers | |||
* @property array|'' $ldapBaseGroups | |||
* @property string $ldapAgentName | |||
* @property string $ldapAgentPassword | |||
* @property string $ldapTLS | |||
* @property string $turnOffCertCheck | |||
* @property string $ldapIgnoreNamingRules | |||
* @property string $ldapUserDisplayName | |||
* @property string $ldapUserDisplayName2 | |||
* @property string $ldapUserAvatarRule | |||
* @property string $ldapGidNumber | |||
* @property array|'' $ldapUserFilterObjectclass | |||
* @property array|'' $ldapUserFilterGroups | |||
* @property string $ldapUserFilter | |||
* @property string $ldapUserFilterMode | |||
* @property string $ldapGroupFilter | |||
* @property string $ldapGroupFilterMode | |||
* @property array|'' $ldapGroupFilterObjectclass | |||
* @property array|'' $ldapGroupFilterGroups | |||
* @property string $ldapGroupDisplayName | |||
* @property string $ldapGroupMemberAssocAttr | |||
* @property string $ldapLoginFilter | |||
* @property string $ldapLoginFilterMode | |||
* @property string $ldapLoginFilterEmail | |||
* @property string $ldapLoginFilterUsername | |||
* @property array|'' $ldapLoginFilterAttributes | |||
* @property string $ldapQuotaAttribute | |||
* @property string $ldapQuotaDefault | |||
* @property string $ldapEmailAttribute | |||
* @property string $ldapCacheTTL | |||
* @property string $ldapUuidUserAttribute | |||
* @property string $ldapUuidGroupAttribute | |||
* @property string $ldapOverrideMainServer | |||
* @property string $ldapConfigurationActive | |||
* @property array|'' $ldapAttributesForUserSearch | |||
* @property array|'' $ldapAttributesForGroupSearch | |||
* @property string $ldapExperiencedAdmin | |||
* @property string $homeFolderNamingRule | |||
* @property string $hasMemberOfFilterSupport | |||
* @property string $useMemberOfToDetectMembership | |||
* @property string $ldapExpertUsernameAttr | |||
* @property string $ldapExpertUUIDUserAttr | |||
* @property string $ldapExpertUUIDGroupAttr | |||
* @property string $markRemnantsAsDisabled | |||
* @property string $lastJpegPhotoLookup | |||
* @property string $ldapNestedGroups | |||
* @property string $ldapPagingSize | |||
* @property string $turnOnPasswordChange | |||
* @property string $ldapDynamicGroupMemberURL | |||
* @property string $ldapDefaultPPolicyDN | |||
* @property string $ldapExtStorageHomeAttribute | |||
* @property string $ldapMatchingRuleInChainState | |||
* @property string $ldapConnectionTimeout | |||
* @property string $ldapAttributePhone | |||
* @property string $ldapAttributeWebsite | |||
* @property string $ldapAttributeAddress | |||
* @property string $ldapAttributeTwitter | |||
* @property string $ldapAttributeFediverse | |||
* @property string $ldapAttributeOrganisation | |||
* @property string $ldapAttributeRole | |||
* @property string $ldapAttributeHeadline | |||
* @property string $ldapAttributeBiography | |||
* @property string $ldapAdminGroup | |||
*/ | |||
class Configuration { | |||
public const AVATAR_PREFIX_DEFAULT = 'default'; |
@@ -41,49 +41,79 @@ use OC\ServerNotAvailableException; | |||
use Psr\Log\LoggerInterface; | |||
/** | |||
* magic properties (incomplete) | |||
* magic properties | |||
* responsible for LDAP connections in context with the provided configuration | |||
* | |||
* @property string ldapHost | |||
* @property string ldapPort holds the port number | |||
* @property string ldapUserFilter | |||
* @property string ldapUserDisplayName | |||
* @property string ldapUserDisplayName2 | |||
* @property string ldapUserAvatarRule | |||
* @property boolean turnOnPasswordChange | |||
* @property string[] ldapBaseUsers | |||
* @property int|null ldapPagingSize holds an integer | |||
* @property bool|mixed|void ldapGroupMemberAssocAttr | |||
* @property string ldapUuidUserAttribute | |||
* @property string ldapUuidGroupAttribute | |||
* @property string ldapExpertUUIDUserAttr | |||
* @property string ldapExpertUUIDGroupAttr | |||
* @property string ldapQuotaAttribute | |||
* @property string ldapQuotaDefault | |||
* @property string ldapEmailAttribute | |||
* @property string ldapExtStorageHomeAttribute | |||
* @property string homeFolderNamingRule | |||
* @property bool|string markRemnantsAsDisabled | |||
* @property bool|string ldapNestedGroups | |||
* @property string[] ldapBaseGroups | |||
* @property string ldapGroupFilter | |||
* @property string ldapGroupDisplayName | |||
* @property string ldapLoginFilter | |||
* @property string ldapDynamicGroupMemberURL | |||
* @property string ldapGidNumber | |||
* @property int hasMemberOfFilterSupport | |||
* @property int useMemberOfToDetectMembership | |||
* @property string ldapMatchingRuleInChainState | |||
* @property string ldapAttributePhone | |||
* @property string ldapAttributeWebsite | |||
* @property string ldapAttributeAddress | |||
* @property string ldapAttributeTwitter | |||
* @property string ldapAttributeFediverse | |||
* @property string ldapAttributeOrganisation | |||
* @property string ldapAttributeRole | |||
* @property string ldapAttributeHeadline | |||
* @property string ldapAttributeBiography | |||
* @property string ldapAdminGroup | |||
* @property string $ldapHost | |||
* @property string $ldapPort | |||
* @property string $ldapBackupHost | |||
* @property string $ldapBackupPort | |||
* @property string $ldapBackgroundHost | |||
* @property string $ldapBackgroundPort | |||
* @property array|'' $ldapBase | |||
* @property array|'' $ldapBaseUsers | |||
* @property array|'' $ldapBaseGroups | |||
* @property string $ldapAgentName | |||
* @property string $ldapAgentPassword | |||
* @property string $ldapTLS | |||
* @property string $turnOffCertCheck | |||
* @property string $ldapIgnoreNamingRules | |||
* @property string $ldapUserDisplayName | |||
* @property string $ldapUserDisplayName2 | |||
* @property string $ldapUserAvatarRule | |||
* @property string $ldapGidNumber | |||
* @property array|'' $ldapUserFilterObjectclass | |||
* @property array|'' $ldapUserFilterGroups | |||
* @property string $ldapUserFilter | |||
* @property string $ldapUserFilterMode | |||
* @property string $ldapGroupFilter | |||
* @property string $ldapGroupFilterMode | |||
* @property array|'' $ldapGroupFilterObjectclass | |||
* @property array|'' $ldapGroupFilterGroups | |||
* @property string $ldapGroupDisplayName | |||
* @property string $ldapGroupMemberAssocAttr | |||
* @property string $ldapLoginFilter | |||
* @property string $ldapLoginFilterMode | |||
* @property string $ldapLoginFilterEmail | |||
* @property string $ldapLoginFilterUsername | |||
* @property array|'' $ldapLoginFilterAttributes | |||
* @property string $ldapQuotaAttribute | |||
* @property string $ldapQuotaDefault | |||
* @property string $ldapEmailAttribute | |||
* @property string $ldapCacheTTL | |||
* @property string $ldapUuidUserAttribute | |||
* @property string $ldapUuidGroupAttribute | |||
* @property string $ldapOverrideMainServer | |||
* @property string $ldapConfigurationActive | |||
* @property array|'' $ldapAttributesForUserSearch | |||
* @property array|'' $ldapAttributesForGroupSearch | |||
* @property string $ldapExperiencedAdmin | |||
* @property string $homeFolderNamingRule | |||
* @property string $hasMemberOfFilterSupport | |||
* @property string $useMemberOfToDetectMembership | |||
* @property string $ldapExpertUsernameAttr | |||
* @property string $ldapExpertUUIDUserAttr | |||
* @property string $ldapExpertUUIDGroupAttr | |||
* @property string $markRemnantsAsDisabled | |||
* @property string $lastJpegPhotoLookup | |||
* @property string $ldapNestedGroups | |||
* @property string $ldapPagingSize | |||
* @property string $turnOnPasswordChange | |||
* @property string $ldapDynamicGroupMemberURL | |||
* @property string $ldapDefaultPPolicyDN | |||
* @property string $ldapExtStorageHomeAttribute | |||
* @property string $ldapMatchingRuleInChainState | |||
* @property string $ldapConnectionTimeout | |||
* @property string $ldapAttributePhone | |||
* @property string $ldapAttributeWebsite | |||
* @property string $ldapAttributeAddress | |||
* @property string $ldapAttributeTwitter | |||
* @property string $ldapAttributeFediverse | |||
* @property string $ldapAttributeOrganisation | |||
* @property string $ldapAttributeRole | |||
* @property string $ldapAttributeHeadline | |||
* @property string $ldapAttributeBiography | |||
* @property string $ldapAdminGroup | |||
*/ | |||
class Connection extends LDAPUtility { | |||
private ?\LDAP\Connection $ldapConnectionRes = null; |
@@ -57,13 +57,13 @@ class Generate extends Command { | |||
protected function execute(InputInterface $input, OutputInterface $output): int { | |||
$fileInput = $input->getArgument("file"); | |||
$sizes = $input->getOption("size"); | |||
$sizes = array_map(function (string $size) use ($output, &$error) { | |||
$sizes = array_map(function (string $size) use ($output) { | |||
if (str_contains($size, 'x')) { | |||
$sizeParts = explode('x', $size, 2); | |||
} else { | |||
$sizeParts = [$size, $size]; | |||
} | |||
if (!is_numeric($sizeParts[0]) || !is_numeric($sizeParts[1])) { | |||
if (!is_numeric($sizeParts[0]) || !is_numeric($sizeParts[1] ?? null)) { | |||
$output->writeln("<error>Invalid size $size</error>"); | |||
return null; | |||
} |
@@ -57,12 +57,12 @@ use Symfony\Component\HttpFoundation\IpUtils; | |||
* Class for accessing variables in the request. | |||
* This class provides an immutable object with request variables. | |||
* | |||
* @property mixed[] cookies | |||
* @property mixed[] env | |||
* @property mixed[] files | |||
* @property string method | |||
* @property mixed[] parameters | |||
* @property mixed[] server | |||
* @property mixed[] $cookies | |||
* @property mixed[] $env | |||
* @property mixed[] $files | |||
* @property string $method | |||
* @property mixed[] $parameters | |||
* @property mixed[] $server | |||
* @template-implements \ArrayAccess<string,mixed> | |||
*/ | |||
class Request implements \ArrayAccess, \Countable, IRequest { |
@@ -228,8 +228,8 @@ class SimpleContainer implements ArrayAccess, ContainerInterface, IContainer { | |||
/** | |||
* @deprecated 20.0.0 use \OCP\IContainer::registerService | |||
*/ | |||
public function offsetSet($id, $service): void { | |||
$this->container->offsetSet($id, $service); | |||
public function offsetSet($offset, $value): void { | |||
$this->container->offsetSet($offset, $value); | |||
} | |||
/** |
@@ -524,6 +524,7 @@ class Local extends \OC\Files\Storage\Common { | |||
$realPath = realpath($pathToResolve); | |||
while ($realPath === false) { // for non existing files check the parent directory | |||
$currentPath = dirname($currentPath); | |||
/** @psalm-suppress TypeDoesNotContainType Let's be extra cautious and still check for empty string */ | |||
if ($currentPath === '' || $currentPath === '.') { | |||
return $fullPath; | |||
} |
@@ -98,26 +98,15 @@ class Manager extends PublicEmitter implements IGroupManager { | |||
$this->logger = $logger; | |||
$this->displayNameCache = new DisplayNameCache($cacheFactory, $this); | |||
$cachedGroups = &$this->cachedGroups; | |||
$cachedUserGroups = &$this->cachedUserGroups; | |||
$this->listen('\OC\Group', 'postDelete', function ($group) use (&$cachedGroups, &$cachedUserGroups) { | |||
/** | |||
* @var \OC\Group\Group $group | |||
*/ | |||
unset($cachedGroups[$group->getGID()]); | |||
$cachedUserGroups = []; | |||
$this->listen('\OC\Group', 'postDelete', function (IGroup $group): void { | |||
unset($this->cachedGroups[$group->getGID()]); | |||
$this->cachedUserGroups = []; | |||
}); | |||
$this->listen('\OC\Group', 'postAddUser', function ($group) use (&$cachedUserGroups) { | |||
/** | |||
* @var \OC\Group\Group $group | |||
*/ | |||
$cachedUserGroups = []; | |||
$this->listen('\OC\Group', 'postAddUser', function (IGroup $group): void { | |||
$this->cachedUserGroups = []; | |||
}); | |||
$this->listen('\OC\Group', 'postRemoveUser', function ($group) use (&$cachedUserGroups) { | |||
/** | |||
* @var \OC\Group\Group $group | |||
*/ | |||
$cachedUserGroups = []; | |||
$this->listen('\OC\Group', 'postRemoveUser', function (IGroup $group): void { | |||
$this->cachedUserGroups = []; | |||
}); | |||
} | |||
@@ -47,7 +47,7 @@ class MimeIconProvider implements IMimeIconProvider { | |||
$aliases = $this->mimetypeDetector->getAllAliases(); | |||
// Remove comments | |||
$aliases = array_filter($aliases, static function ($key) { | |||
$aliases = array_filter($aliases, static function (string $key) { | |||
return !($key === '' || $key[0] === '_'); | |||
}, ARRAY_FILTER_USE_KEY); | |||
@@ -79,35 +79,26 @@ class Manager extends PublicEmitter implements IUserManager { | |||
/** | |||
* @var \OCP\UserInterface[] $backends | |||
*/ | |||
private $backends = []; | |||
private array $backends = []; | |||
/** | |||
* @var \OC\User\User[] $cachedUsers | |||
* @var array<string,\OC\User\User> $cachedUsers | |||
*/ | |||
private $cachedUsers = []; | |||
private array $cachedUsers = []; | |||
/** @var IConfig */ | |||
private $config; | |||
/** @var ICache */ | |||
private $cache; | |||
/** @var IEventDispatcher */ | |||
private $eventDispatcher; | |||
private ICache $cache; | |||
private DisplayNameCache $displayNameCache; | |||
public function __construct(IConfig $config, | |||
public function __construct( | |||
private IConfig $config, | |||
ICacheFactory $cacheFactory, | |||
IEventDispatcher $eventDispatcher) { | |||
$this->config = $config; | |||
private IEventDispatcher $eventDispatcher, | |||
) { | |||
$this->cache = new WithLocalCache($cacheFactory->createDistributed('user_backend_map')); | |||
$cachedUsers = &$this->cachedUsers; | |||
$this->listen('\OC\User', 'postDelete', function ($user) use (&$cachedUsers) { | |||
/** @var \OC\User\User $user */ | |||
unset($cachedUsers[$user->getUID()]); | |||
$this->listen('\OC\User', 'postDelete', function (IUser $user): void { | |||
unset($this->cachedUsers[$user->getUID()]); | |||
}); | |||
$this->eventDispatcher = $eventDispatcher; | |||
$this->displayNameCache = new DisplayNameCache($cacheFactory, $this); | |||
} | |||