Skip to content

Commit

Permalink
Merge pull request #662 from nextcloud/groupbackend-upup
Browse files Browse the repository at this point in the history
Implementation of Groupbackend II
  • Loading branch information
blizzz committed Dec 20, 2023
2 parents dd670cb + 84ec0aa commit 4dbbd8e
Show file tree
Hide file tree
Showing 25 changed files with 2,127 additions and 122 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@ jobs:
mkdir data
./occ maintenance:install --verbose --database=${{ matrix.databases }} --database-name=nextcloud --database-host=127.0.0.1 --database-port=$DB_PORT --database-user=root --database-pass=rootpassword --admin-user admin --admin-pass admin
./occ app:enable --force ${{ env.APP_NAME }}
cat << EOF > config/debug.config.php
<?php
\$CONFIG = [
'log.condition' => ['apps' => ['user_saml']],
];
EOF
PHP_CLI_SERVER_WORKERS=4 php -S localhost:8080 &
- name: Run behat
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/phpunit-oci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ concurrency:

jobs:
phpunit-oci:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04

strategy:
matrix:
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# Changelog
All notable changes to this project will be documented in this file.

## 6.1.0

### Added

- [Group backend and migration of original SAML groups created as local database groups (user_saml#622)](https://github.com/nextcloud/user_saml/pull/622)

## 6.0.1

### Added
Expand Down
35 changes: 14 additions & 21 deletions appinfo/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,15 @@
*
*/

use OCA\User_SAML\GroupBackend;
use OCA\User_SAML\SAMLSettings;
use OCA\User_SAML\UserBackend;
use OCP\IGroupManager;
use Psr\Log\LoggerInterface;

require_once __DIR__ . '/../3rdparty/vendor/autoload.php';

// If we run in CLI mode do not setup the app as it can fail the OCC execution
// If we run in CLI mode do not set up the app as it can fail the OCC execution
// since the URLGenerator isn't accessible.
$cli = false;
if (OC::$CLI) {
Expand All @@ -35,30 +41,17 @@
$userSession = \OC::$server->getUserSession();
$session = \OC::$server->getSession();
} catch (Throwable $e) {
$logger = \OCP\Server::get(\Psr\Log\LoggerInterface::class);
$logger = \OCP\Server::get(LoggerInterface::class);
$logger->critical($e->getMessage(), ['exception' => $e, 'app' => 'user_saml']);
return;
}

$samlSettings = \OC::$server->query(\OCA\User_SAML\SAMLSettings::class);

$userData = new \OCA\User_SAML\UserData(
new \OCA\User_SAML\UserResolver(\OC::$server->getUserManager()),
$samlSettings,
);

$userBackend = new \OCA\User_SAML\UserBackend(
$config,
$urlGenerator,
\OC::$server->getSession(),
\OC::$server->getDatabaseConnection(),
\OC::$server->getUserManager(),
\OC::$server->getGroupManager(),
$samlSettings,
\OCP\Server::get(\Psr\Log\LoggerInterface::class),
$userData,
\OC::$server->query(\OCP\EventDispatcher\IEventDispatcher::class),
);
$groupBackend = \OC::$server->get(GroupBackend::class);
\OC::$server->get(IGroupManager::class)->addBackend($groupBackend);

$samlSettings = \OC::$server->get(SAMLSettings::class);

$userBackend = \OCP\Server::get(UserBackend::class);
$userBackend->registerBackends(\OC::$server->getUserManager()->getBackends());
OC_User::useBackend($userBackend);

Expand Down
7 changes: 6 additions & 1 deletion appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ The following providers are supported and tested at the moment:
* Any other provider that authenticates using the environment variable
While theoretically any other authentication provider implementing either one of those standards is compatible, we like to note that they are not part of any internal test matrix.]]></description>
<version>6.0.1</version>
<version>6.1.0</version>
<licence>agpl</licence>
<author>Lukas Reschke</author>
<namespace>User_SAML</namespace>
Expand All @@ -35,6 +35,11 @@ While theoretically any other authentication provider implementing either one of
<dependencies>
<nextcloud min-version="28" max-version="29" />
</dependencies>
<repair-steps>
<post-migration>
<step>OCA\User_SAML\Migration\RememberLocalGroupsForPotentialMigrations</step>
</post-migration>
</repair-steps>
<commands>
<command>OCA\User_SAML\Command\ConfigCreate</command>
<command>OCA\User_SAML\Command\ConfigDelete</command>
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@
"nextcloud/coding-standard": "^1.1",
"phpunit/phpunit": "^9",
"psalm/phar": "^5.13",
"nextcloud/ocp": "^27.0"
"nextcloud/ocp": "dev-stable27"
}
}
22 changes: 12 additions & 10 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions lib/Exceptions/GroupNotFoundException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

declare(strict_types=1);

/**
* @copyright Copyright (c) 2022 Arthur Schiwon <[email protected]>
*
* @author Arthur Schiwon <[email protected]>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/

namespace OCA\User_SAML\Exceptions;

class GroupNotFoundException extends \RuntimeException {
}
30 changes: 30 additions & 0 deletions lib/Exceptions/NonMigratableGroupException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

declare(strict_types=1);

/**
* @copyright Copyright (c) 2022 Arthur Schiwon <[email protected]>
*
* @author Arthur Schiwon <[email protected]>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/

namespace OCA\User_SAML\Exceptions;

class NonMigratableGroupException extends \RuntimeException {
}
Loading

0 comments on commit 4dbbd8e

Please sign in to comment.