Skip to content

Commit 5e2abff

Browse files
committed
WIP move to SSP UI
1 parent f94c683 commit 5e2abff

23 files changed

+172
-41
lines changed

hooks/hook_adminmenu.php

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,22 @@ function oidc_hook_adminmenu(Template &$template): void
2525
],
2626
];
2727

28-
// Put our entry before the "Log out" entry.
29-
array_splice($template->data[$menuKey], -1, 0, $oidcMenuEntry);
28+
// Put OIDC entry before the 'Log out' entry, if it exists.
29+
$logoutEntryKey = 'logout';
30+
$logoutEntryValue = null;
31+
if (
32+
array_key_exists($logoutEntryKey, $template->data[$menuKey]) &&
33+
is_array($template->data[$menuKey][$logoutEntryKey])
34+
) {
35+
$logoutEntryValue = $template->data[$menuKey][$logoutEntryKey];
36+
unset($template->data[$menuKey][$logoutEntryKey]);
37+
}
38+
39+
$template->data[$menuKey] += $oidcMenuEntry;
40+
41+
if ($logoutEntryValue !== null) {
42+
$template->data[$menuKey][$logoutEntryKey] = $logoutEntryValue;
43+
}
3044

3145
$template->getLocalization()->addModuleDomain(ModuleConfig::MODULE_NAME);
3246
}

public/assets/css/src/default.css

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
.wrap {
2-
max-width: 1300px;
2+
/*max-width: 1300px;*/
33
}
44

5-
h2 {
6-
margin: 0.3em;
7-
}
5+
/*h2 {*/
6+
/* margin: 0.3em;*/
7+
/*}*/
88

99
h3 {
1010
margin-bottom: 0.5em;

src/Bridges/SspBridge/Module.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,27 @@
55
namespace SimpleSAML\Module\oidc\Bridges\SspBridge;
66

77
use SimpleSAML\Module as SspModule;
8+
use SimpleSAML\Module\oidc\Bridges\SspBridge\Module\Admin;
89

910
class Module
1011
{
12+
protected static ?SspModule\oidc\Bridges\SspBridge\Module\Admin $admin = null;
13+
14+
public function admin(): Admin
15+
{
16+
return self::$admin ??= new Admin();
17+
}
18+
1119
public function getModuleUrl(string $resource, array $parameters = []): string
1220
{
1321
return SspModule::getModuleURL($resource, $parameters);
1422
}
23+
24+
/**
25+
* @throws \Exception
26+
*/
27+
public function isModuleEnabled(string $moduleName): bool
28+
{
29+
return SspModule::isModuleEnabled($moduleName);
30+
}
1531
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace SimpleSAML\Module\oidc\Bridges\SspBridge\Module;
6+
7+
use SimpleSAML\Module\admin\Controller\Menu;
8+
9+
class Admin
10+
{
11+
public function buildSspAdminMenu(): Menu
12+
{
13+
return new Menu();
14+
}
15+
}

src/Controller/AdminController.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace SimpleSAML\Module\oidc\Controller;
66

77
use SimpleSAML\Module\oidc\Admin\Authorization;
8+
use SimpleSAML\Module\oidc\Codebooks\RoutesEnum;
89
use SimpleSAML\Module\oidc\Factories\TemplateFactory;
910
use SimpleSAML\Module\oidc\ModuleConfig;
1011
use Symfony\Component\HttpFoundation\Response;
@@ -21,11 +22,10 @@ public function __construct(
2122

2223
public function configOverview(): Response
2324
{
24-
return $this->templateFactory->render(
25+
return $this->templateFactory->build(
2526
'oidc:config/overview.twig',
26-
[
27-
'moduleConfig' => $this->moduleConfig,
28-
],
27+
['moduleConfig' => $this->moduleConfig],
28+
RoutesEnum::AdminConfigOverview->value,
2929
);
3030
}
3131
}

src/Controller/Client/CreateController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public function __invoke(): Template|RedirectResponse
135135
return new RedirectResponse((new HTTP())->addURLParameters('show.php', ['client_id' => $client['id']]));
136136
}
137137

138-
return $this->templateFactory->render('oidc:clients/new.twig', [
138+
return $this->templateFactory->build('oidc:clients/new.twig', [
139139
'form' => $form,
140140
'regexUri' => ClientForm::REGEX_URI,
141141
'regexAllowedOriginUrl' => ClientForm::REGEX_ALLOWED_ORIGIN_URL,

src/Controller/Client/DeleteController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public function __invoke(ServerRequest $request): Template|RedirectResponse
7171
return new RedirectResponse((new HTTP())->addURLParameters('index.php', []));
7272
}
7373

74-
return $this->templateFactory->render('oidc:clients/delete.twig', [
74+
return $this->templateFactory->build('oidc:clients/delete.twig', [
7575
'client' => $client,
7676
]);
7777
}

src/Controller/Client/EditController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ public function __invoke(ServerRequest $request): Template|RedirectResponse
143143
);
144144
}
145145

146-
return $this->templateFactory->render('oidc:clients/edit.twig', [
146+
return $this->templateFactory->build('oidc:clients/edit.twig', [
147147
'form' => $form,
148148
'regexUri' => ClientForm::REGEX_URI,
149149
'regexAllowedOriginUrl' => ClientForm::REGEX_ALLOWED_ORIGIN_URL,

src/Controller/Client/IndexController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function __invoke(ServerRequest $request): Template
4444
$authedUser = $this->authContextService->isSspAdmin() ? null : $this->authContextService->getAuthUserId();
4545
$pagination = $this->clientRepository->findPaginated($page, $query, $authedUser);
4646

47-
return $this->templateFactory->render('oidc:clients/index.twig', [
47+
return $this->templateFactory->build('oidc:clients/index.twig', [
4848
'clients' => $pagination['items'],
4949
'numPages' => $pagination['numPages'],
5050
'currentPage' => $pagination['currentPage'],

src/Controller/Client/ShowController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function __invoke(ServerRequest $request): Template
4949
$client = $this->getClientFromRequest($request);
5050
$allowedOrigins = $this->allowedOriginRepository->get($client->getIdentifier());
5151

52-
return $this->templateFactory->render('oidc:clients/show.twig', [
52+
return $this->templateFactory->build('oidc:clients/show.twig', [
5353
'client' => $client,
5454
'allowedOrigins' => $allowedOrigins,
5555
]);

0 commit comments

Comments
 (0)