Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"cs:fix": "@php php-cs-fixer fix",
"cs:check": "@php php-cs-fixer fix --dry-run --diff",
"psalm": "@php psalm",
"psalm:fix": "@php psalm --alter --issues=InvalidReturnType,InvalidNullableReturnType,MissingParamType,InvalidFalsableReturnType",
"psalm:fix": "@php psalm --alter --issues=InvalidReturnType,InvalidNullableReturnType,MissingParamType,InvalidFalsableReturnType,MissingOverrideAttribute",
"psalm:update-baseline": "@php psalm --threads=1 --update-baseline",
"lint": "find . -name \\*.php -not -path '*/vendor/*' -print0 | xargs -0 -n1 php -l",
"rector:check": "rector --dry-run",
Expand Down
2 changes: 2 additions & 0 deletions lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public function __construct(array $urlParams = []) {
parent::__construct('user_saml', $urlParams);
}

#[\Override]
public function register(IRegistrationContext $context): void {
$context->registerMiddleware(OnlyLoggedInMiddleware::class);
$context->registerEventListener(BeforeTemplateRenderedEvent::class, LoadAdditionalScriptsListener::class);
Expand All @@ -72,6 +73,7 @@ public function register(IRegistrationContext $context): void {
));
}

#[\Override]
public function boot(IBootContext $context): void {
try {
$context->injectFn(function (
Expand Down
1 change: 1 addition & 0 deletions lib/Command/ConfigCreate.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public function __construct(
parent::__construct();
}

#[\Override]
protected function configure(): void {
$this->setName('saml:config:create');
$this->setDescription('Creates a new config and prints the new provider ID');
Expand Down
1 change: 1 addition & 0 deletions lib/Command/ConfigDelete.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public function __construct(
parent::__construct();
}

#[\Override]
protected function configure(): void {
$this->setName('saml:config:delete');

Expand Down
1 change: 1 addition & 0 deletions lib/Command/ConfigGet.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public function __construct(
parent::__construct();
}

#[\Override]
protected function configure(): void {
$this->setName('saml:config:get');

Expand Down
1 change: 1 addition & 0 deletions lib/Command/ConfigSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public function __construct(
parent::__construct();
}

#[\Override]
protected function configure(): void {
$this->setName('saml:config:set');

Expand Down
2 changes: 2 additions & 0 deletions lib/Command/GetMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public function __construct(
parent::__construct();
}

#[\Override]
protected function configure(): void {
$this
->setName('saml:metadata')
Expand All @@ -45,6 +46,7 @@ protected function configure(): void {
;
}

#[\Override]
protected function execute(InputInterface $input, OutputInterface $output): int {
$idp = (int)$input->getArgument('idp');
$settingsArray = $this->samlSettings->getOneLoginSettingsArray($idp);
Expand Down
1 change: 1 addition & 0 deletions lib/Command/GroupMigrationCopyIncomplete.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public function __construct(
) {
parent::__construct();
}
#[\Override]
protected function configure(): void {
$this->setName('saml:group-migration:copy-incomplete-members');
$this->setDescription('Transfers remaining group members from old local to current SAML groups');
Expand Down
1 change: 1 addition & 0 deletions lib/Command/UserAdd.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public function __construct(
) {
parent::__construct();
}
#[\Override]
protected function configure(): void {
$this
->setName('saml:user:add')
Expand Down
1 change: 1 addition & 0 deletions lib/DavPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public function __construct(
) {
}

#[\Override]
public function initialize(Server $server): void {
$server->on('beforeMethod:*', $this->beforeMethod(...), 9);
$this->server = $server;
Expand Down
15 changes: 14 additions & 1 deletion lib/GroupBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public function __construct(
) {
}

#[\Override]
public function inGroup($uid, $gid): bool {
$qb = $this->dbc->getQueryBuilder();
$stmt = $qb->select('gid')
Expand All @@ -52,6 +53,7 @@ public function inGroup($uid, $gid): bool {
/**
* @return list<string> Group names
*/
#[\Override]
public function getUserGroups($uid): array {
$qb = $this->dbc->getQueryBuilder();
$cursor = $qb->select('gid')
Expand All @@ -71,7 +73,8 @@ public function getUserGroups($uid): array {
/**
* @return string[] Group names
*/
public function getGroups($search = '', $limit = null, $offset = null): array {
#[\Override]
public function getGroups(string $search = '', $limit = null, $offset = null): array {
$query = $this->dbc->getQueryBuilder();
$query->select('gid', 'displayname')
->from(self::TABLE_GROUPS)
Expand Down Expand Up @@ -108,6 +111,7 @@ public function getGroups($search = '', $limit = null, $offset = null): array {
* @param string $gid
* @return bool
*/
#[\Override]
public function groupExists($gid): bool {
if (isset($this->groupCache[$gid])) {
return true;
Expand Down Expand Up @@ -151,6 +155,7 @@ public function groupExistsWithDifferentGid(string $samlGid): ?string {
* @param int $offset
* @return array<int,string> User ids
*/
#[\Override]
public function usersInGroup($gid, $search = '', $limit = -1, $offset = 0): array {
$query = $this->dbc->getQueryBuilder();
$query->select('uid')
Expand Down Expand Up @@ -182,6 +187,7 @@ public function usersInGroup($gid, $search = '', $limit = -1, $offset = 0): arra
return $users;
}

#[\Override]
public function createGroup(string $gid, ?string $samlGid = null): bool {
try {
// Add group
Expand Down Expand Up @@ -213,6 +219,7 @@ public function createGroup(string $gid, ?string $samlGid = null): bool {
/**
* @throws Exception
*/
#[\Override]
public function addToGroup(string $uid, string $gid): bool {
if ($this->inGroup($uid, $gid)) {
return true;
Expand All @@ -226,6 +233,7 @@ public function addToGroup(string $uid, string $gid): bool {
return true;
}

#[\Override]
public function removeFromGroup(string $uid, string $gid): bool {
$qb = $this->dbc->getQueryBuilder();
$rows = $qb->delete(self::TABLE_MEMBERS)
Expand All @@ -236,6 +244,7 @@ public function removeFromGroup(string $uid, string $gid): bool {
return $rows > 0;
}

#[\Override]
public function countUsersInGroup(string $gid, string $search = ''): int {
$query = $this->dbc->getQueryBuilder();
$query->select($query->func()->count('*', 'num_users'))
Expand All @@ -261,6 +270,7 @@ public function countUsersInGroup(string $gid, string $search = ''): int {
return $count;
}

#[\Override]
public function deleteGroup(string $gid): bool {
$query = $this->dbc->getQueryBuilder();

Expand All @@ -287,10 +297,12 @@ public function deleteGroup(string $gid): bool {
return true;
}

#[\Override]
public function getBackendName(): string {
return 'user_saml';
}

#[\Override]
public function getDisplayName(string $gid): string {
if (!isset($this->groupCache[$gid])) {
$this->getGroups($gid);
Expand All @@ -299,6 +311,7 @@ public function getDisplayName(string $gid): string {
return $this->groupCache[$gid] ?? $gid;
}

#[\Override]
public function setDisplayName(string $gid, string $displayName): bool {
if (!$this->groupExists($gid)) {
return false;
Expand Down
5 changes: 4 additions & 1 deletion lib/GroupManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,10 @@ protected function unassignUserFromGroup(IUser $user, string $gid): void {
}
}

protected function handleUserAssignedToGroups(IUser $user, $groupIds): void {
/**
* @param array<string> $groupIds
*/
protected function handleUserAssignedToGroups(IUser $user, array $groupIds): void {
foreach ($groupIds as $gid) {
$this->assignUserToGroup($user, $gid);
}
Expand Down
1 change: 1 addition & 0 deletions lib/Jobs/CleanSessionData.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public function __construct(
$this->setAllowParallelRuns(false);
}

#[\Override]
protected function run(mixed $argument): void {
$missingSessionIds = $this->findInvalidatedSessions();
$this->deleteInvalidatedSessions($missingSessionIds);
Expand Down
1 change: 1 addition & 0 deletions lib/Jobs/MigrateGroups.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public function __construct(
parent::__construct($timeFactory);
}

#[\Override]
protected function run($argument) {
try {
$candidates = $this->getMigratableGroups();
Expand Down
1 change: 1 addition & 0 deletions lib/Listener/CookieLoginEventListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public function __construct(
) {
}

#[\Override]
public function handle(Event $event): void {
if ($event instanceof BeforeUserLoggedInWithCookieEvent) {
$this->prepareRestoreOfSession();
Expand Down
1 change: 1 addition & 0 deletions lib/Listener/LoadAdditionalScriptsListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public function __construct(
) {
}

#[\Override]
public function handle(Event $event): void {
if (!$event instanceof BeforeTemplateRenderedEvent) {
return;
Expand Down
1 change: 1 addition & 0 deletions lib/Listener/LoginEventListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public function __construct(
) {
}

#[\Override]
public function handle(Event $event): void {
if (!$event instanceof UserLoggedInEvent
|| $event->isTokenLogin()
Expand Down
1 change: 1 addition & 0 deletions lib/Listener/SabrePluginEventListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

/** @template-implements IEventListener<SabrePluginAddEvent|Event> */
class SabrePluginEventListener implements IEventListener {
#[\Override]
public function handle(Event $event): void {
if (!$event instanceof SabrePluginAddEvent) {
return;
Expand Down
2 changes: 2 additions & 0 deletions lib/Middleware/OnlyLoggedInMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public function __construct(
* @param string $methodName
* @throws \Exception
*/
#[\Override]
public function beforeController($controller, $methodName) {
if ($this->reflector->hasAnnotation('OnlyUnauthenticatedUsers') && $this->userSession->isLoggedIn()) {
throw new \Exception('User is already logged-in');
Expand All @@ -46,6 +47,7 @@ public function beforeController($controller, $methodName) {
* @return RedirectResponse
* @throws \Exception
*/
#[\Override]
public function afterException($controller, $methodName, \Exception $exception) {
if ($exception->getMessage() === 'User is already logged-in') {
return new RedirectResponse($this->urlGenerator->getAbsoluteURL('/'));
Expand Down
2 changes: 2 additions & 0 deletions lib/Migration/CleanupRemovedConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@ public function __construct(
/**
* @inheritDoc
*/
#[\Override]
public function getName() {
return 'Cleans up config keys that are not used anymore';
}

/**
* @inheritDoc
*/
#[\Override]
public function run(IOutput $output) {
$this->config->deleteAppValue('user_saml', 'general-use_saml_auth_for_desktop');
}
Expand Down
2 changes: 2 additions & 0 deletions lib/Migration/RememberLocalGroupsForPotentialMigrations.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public function __construct(
) {
}

#[\Override]
public function getName(): string {
return 'Remember local groups that might belong to SAML';
}
Expand All @@ -36,6 +37,7 @@ public function getName(): string {
* @throws \Exception in case of failure
* @since 9.1.0
*/
#[\Override]
public function run(IOutput $output) {
$candidateInfo = $this->config->getAppValue('user_saml', GroupManager::LOCAL_GROUPS_CHECK_FOR_MIGRATION, '');
if ($candidateInfo !== '') {
Expand Down
2 changes: 2 additions & 0 deletions lib/Migration/TransferGroupMembers.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ public function __construct(
) {
}

#[\Override]
public function getName(): string {
return 'Move potential left members from old local groups to SAML groups';
}

#[\Override]
public function run(IOutput $output): void {
$groupsToTreat = $this->groupMigration->findGroupsWithLocalMembers();
if (empty($groupsToTreat)) {
Expand Down
1 change: 1 addition & 0 deletions lib/Migration/Version3001Date20200630193443.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class Version3001Date20200630193443 extends SimpleMigrationStep {
* @param array $options
* @return null|ISchemaWrapper
*/
#[\Override]
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
Expand Down
2 changes: 2 additions & 0 deletions lib/Migration/Version5000Date20211025124248.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public function __construct(IDBConnection $dbc) {
* @param array $options
* @return null|ISchemaWrapper
*/
#[\Override]
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
Expand Down Expand Up @@ -104,6 +105,7 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt
* @param Closure():IschemaWrapper $schemaClosure
* @param array $options
*/
#[\Override]
public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void {
$prefixes = $this->fetchPrefixes();
foreach ($prefixes as $prefix) {
Expand Down
1 change: 1 addition & 0 deletions lib/Migration/Version6000Date20220912152700.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class Version6000Date20220912152700 extends SimpleMigrationStep {
/**
* @return null|ISchemaWrapper
*/
#[\Override]
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
Expand Down
1 change: 1 addition & 0 deletions lib/Migration/Version6001Date20240202183823.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class Version6001Date20240202183823 extends SimpleMigrationStep {
* @param array $options
* @return null|ISchemaWrapper
*/
#[\Override]
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
Expand Down
4 changes: 3 additions & 1 deletion lib/Model/SessionData.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public function storeInSession(ISession $session): void {
}
}

#[\Override]
public function jsonSerialize(): array {
return [
self::KEY_IDENTITY_PROVIDER_ID => $this->identityProviderId,
Expand Down Expand Up @@ -83,7 +84,8 @@ public static function fromSession(ISession $session): self {
return self::fromInputArray($retrievedData);
}

#[\Override]
public function __toString(): string {
return \json_encode($this);
return \json_encode($this, \JSON_THROW_ON_ERROR);
}
}
1 change: 1 addition & 0 deletions lib/Service/SessionService.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public function storeSessionDataInDatabase(): void {
$sessionDataModel = SessionDataModel::fromSession($this->session);

$sessionData = new SessionData();
/** @psalm-suppress InvalidArgument setId requires a string not an int */
$sessionData->setId($this->hashSessionId($this->session->getId()));
$sessionData->setTokenId($this->tokenProvider->getToken($this->session->getId())->getId());
$sessionData->setData($sessionDataModel);
Expand Down
Loading
Loading