Skip to content

Commit c8cd675

Browse files
committed
Merge #3 Central customization setup
2 parents f85c935 + 9854bd9 commit c8cd675

File tree

5 files changed

+79
-3
lines changed

5 files changed

+79
-3
lines changed

.github/README.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# MagentaCLOUD user_oidc
2+
3+
Customisation of the Nextcloud delivered OpenID connect app for MagentaCLOUD.
4+
5+
The app extends the standard `user_oidc` Nextcloud app,
6+
see [upstream configuration hints for basic setup](https://github.com/nextcloud/user_oidc/blob/main/README.md)
7+
8+
9+
## Feature: Event-based provisioning (upstream contribution candidate)
10+
The mechanism allows to implement custom puser provisioning logic in a separate Nextcloud app by
11+
registering and handling a attribute change and provisioning event:
12+
13+
```
14+
use OCP\AppFramework\App;
15+
use OCP\AppFramework\Bootstrap\IBootContext;
16+
use OCP\AppFramework\Bootstrap\IBootstrap;
17+
use OCP\AppFramework\Bootstrap\IRegistrationContext;
18+
19+
class Application extends App implements IBootstrap {
20+
...
21+
public function register(IRegistrationContext $context): void {
22+
$context->registerEventListener(AttributeMappedEvent::class, MyUserAttributeListener::class);
23+
$context->registerEventListener(UserAccountChangeEvent::class, MyUserAccountChangeListener::class);
24+
}
25+
...
26+
}
27+
```
28+
The provisioning handler should return a `OCA\UserOIDC\Event\UserAccountChangeResult` object
29+
30+
## Feature: Telekom-specific bearer token
31+
32+
Due to historic reason, Telekom bearer tokens have a close to standard structure, but
33+
require special security implementation in detail. The customisation overrides te standard
34+
35+
36+
### Requiring web-token libraries
37+
The central configuration branch `nmc/2372-central-setup` automatic merge will frequently fail if composer
38+
upstream
39+
40+
The fast and easy way to bring it back to sync with upstream is:
41+
```
42+
git checkout nmc/2372-central-setup
43+
git rebase --onto main nmc/2372-central-setup
44+
# manually take over everything from upstream for composer.lock (TODO: automate that)
45+
46+
# ALWAYS update web-token dependencies in composer.lock
47+
# to avoid upstream conflicts. The lock file diff should only contain adds to upstream state!
48+
composer update "web-token/jwt-*"
49+
```
50+
51+
52+
### Configuring an additional Bearer preshared secret with provider
53+
TODO
54+
55+
### Testing Bearer secrets
56+
TODO

COPYING.DTAG

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Although this Nextcloud app code is free and available under the AGPL3 license, Deutsche Telekom
2+
(including T-Systems) fully reserves all rights to the Telekom brand. To prevent users from getting confused about
3+
the source of a digital product or experience, there are stringent restrictions on using the Telekom brand and design,
4+
even when built into code that we provide. For any customization other than explicitly for Telekom or T-Systems, you must
5+
replace the Deutsche Telekom and T-Systems brand elements contained in the provided sources.

appinfo/routes.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,11 @@
2929
['name' => 'login#code', 'url' => '/code', 'verb' => 'GET'],
3030
['name' => 'login#singleLogoutService', 'url' => '/sls', 'verb' => 'GET'],
3131
['name' => 'login#backChannelLogout', 'url' => '/backchannel-logout/{providerIdentifier}', 'verb' => 'POST'],
32+
// compatibility with NMC V24 until reconfig on SAM
33+
['name' => 'login#telekomBackChannelLogout', 'url' => '/logout', 'verb' => 'POST'],
3234

33-
['name' => 'api#createUser', 'url' => '/user', 'verb' => 'POST'],
35+
// this is a security problem combined with Telekom provisioning, so we habe to disable the endpoint
36+
// ['name' => 'api#createUser', 'url' => '/user', 'verb' => 'POST'],
3437

3538
['name' => 'id4me#showLogin', 'url' => '/id4me', 'verb' => 'GET'],
3639
['name' => 'id4me#login', 'url' => '/id4me', 'verb' => 'POST'],

lib/AppInfo/Application.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@
3333
use OCA\UserOIDC\Listener\TimezoneHandlingListener;
3434
use OCA\UserOIDC\Service\ID4MeService;
3535
use OCA\UserOIDC\Service\SettingsService;
36-
use OCA\UserOIDC\User\Backend;
36+
use OCA\UserOIDC\Service\ProvisioningService;
37+
use OCA\UserOIDC\Service\ProvisioningEventService;
38+
use OCA\UserOIDC\MagentaBearer\MBackend;
3739
use OCP\AppFramework\App;
3840
use OCP\AppFramework\Bootstrap\IBootContext;
3941
use OCP\AppFramework\Bootstrap\IBootstrap;
@@ -44,6 +46,7 @@
4446
use OCP\IUserManager;
4547
use OCP\IUserSession;
4648
use Throwable;
49+
use Psr\Container\ContainerInterface;
4750

4851
class Application extends App implements IBootstrap {
4952
public const APP_ID = 'user_oidc';
@@ -57,11 +60,19 @@ public function __construct(array $urlParams = []) {
5760
}
5861

5962
public function register(IRegistrationContext $context): void {
63+
// Register the composer autoloader required for the added jwt-token libs
64+
include_once __DIR__ . '/../../vendor/autoload.php';
65+
66+
// override registration of provisioning srevice to use event-based solution
67+
$this->getContainer()->registerService(ProvisioningService::class, function (ContainerInterface $c): ProvisioningService {
68+
return $c->get(ProvisioningEventService::class);
69+
});
70+
6071
/** @var IUserManager $userManager */
6172
$userManager = $this->getContainer()->get(IUserManager::class);
6273

6374
/* Register our own user backend */
64-
$this->backend = $this->getContainer()->get(Backend::class);
75+
$this->backend = $this->getContainer()->get(MBackend::class);
6576
$userManager->registerBackend($this->backend);
6677
OC_User::useBackend($this->backend);
6778

tests/bootstrap.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
require_once __DIR__.'/../vendor/autoload.php';
2727

2828
\OC::$loader->addValidRoot(OC::$SERVERROOT . '/tests');
29+
\OC::$composerAutoloader->addPsr4('OCA\\UserOIDC\\BaseTest\\', dirname(__FILE__) . '/unit/MagentaCloud/', true);
2930
\OC_App::loadApp('user_oidc');
3031

3132
OC_Hook::clear();

0 commit comments

Comments
 (0)