-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Marko Ivančić
committed
Nov 13, 2024
1 parent
c4393ab
commit f94c683
Showing
17 changed files
with
326 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
.wrap { | ||
max-width: 1300px; | ||
} | ||
|
||
h2 { | ||
margin: 0.3em; | ||
} | ||
|
||
h3 { | ||
margin-bottom: 0.5em; | ||
font-size: 1.2em; | ||
font-weight: 600; | ||
color: #1c1c1c; | ||
} | ||
|
||
h4 { | ||
margin: 0.4em 0; | ||
font-size: 1.0em; | ||
font-weight: 600; | ||
color: #1c1c1c; | ||
} | ||
|
||
/* Container to hold menu and content */ | ||
.oidc-container { | ||
display: flex; | ||
max-width: inherit; | ||
margin: 0 auto; | ||
} | ||
|
||
/* Style for the left menu */ | ||
.menu { | ||
min-width: 200px; | ||
/*background-color: #f4f4f4;*/ | ||
/*border-right: solid 1px #bbb;*/ | ||
width: auto; | ||
} | ||
|
||
/* Style for the menu items */ | ||
.menu ul { | ||
list-style-type: none; | ||
padding: 0; | ||
} | ||
|
||
.menu ul li { | ||
padding: 0.25rem; | ||
} | ||
|
||
.menu ul li a { | ||
text-decoration: none; | ||
color: #333; | ||
display: block; | ||
padding: 0.5rem; | ||
} | ||
|
||
.menu ul li a:hover { | ||
background-color: #ddd; | ||
padding: 0.5rem; | ||
} | ||
|
||
.menu ul li a.active { | ||
background-color: #eeeeee; | ||
padding: 0.5rem; | ||
} | ||
|
||
/* Style for the content area */ | ||
.content { | ||
flex-grow: 1; | ||
padding: 20px; | ||
max-width: inherit; | ||
background-color: #fff; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace SimpleSAML\Module\oidc\Admin; | ||
|
||
use SimpleSAML\Error\Exception; | ||
use SimpleSAML\Locale\Translate; | ||
use SimpleSAML\Module\oidc\Bridges\SspBridge; | ||
use SimpleSAML\Module\oidc\Exceptions\AuthorizationException; | ||
|
||
class Authorization | ||
{ | ||
public function __construct( | ||
protected readonly SspBridge $sspBridge, | ||
) { | ||
} | ||
|
||
/** | ||
* @throws \SimpleSAML\Module\oidc\Exceptions\AuthorizationException | ||
*/ | ||
public function requireSspAdmin(bool $forceAdminAuthentication = false): void | ||
{ | ||
if ($forceAdminAuthentication) { | ||
try { | ||
$this->sspBridge->utils()->auth()->requireAdmin(); | ||
} catch (Exception $exception) { | ||
throw new AuthorizationException( | ||
Translate::noop('Unable to initiate SimpleSAMLphp admin authentication.'), | ||
$exception->getCode(), | ||
$exception, | ||
); | ||
} | ||
} | ||
|
||
if (! $this->sspBridge->utils()->auth()->isAdmin()) { | ||
throw new AuthorizationException(Translate::noop('SimpleSAMLphp admin access required.')); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace SimpleSAML\Module\oidc\Admin; | ||
|
||
use SimpleSAML\Module\oidc\Admin\Menu\Item; | ||
|
||
class Menu | ||
{ | ||
/** | ||
* @var array<Item> | ||
*/ | ||
protected array $items = []; | ||
|
||
protected ?string $activeHrefPath = null; | ||
|
||
public function __construct(Item ...$items) | ||
{ | ||
array_push($this->items, ...$items); | ||
} | ||
|
||
public function addItem(Item $menuItem, int $offset = null): void | ||
{ | ||
$offset ??= count($this->items); | ||
|
||
array_splice($this->items, $offset, 0, [$menuItem]); | ||
} | ||
|
||
public function getItems(): array | ||
{ | ||
return $this->items; | ||
} | ||
|
||
public function setActiveHrefPath(?string $value): void | ||
{ | ||
$this->activeHrefPath = $value; | ||
} | ||
|
||
public function getActiveHrefPath(): ?string | ||
{ | ||
return $this->activeHrefPath; | ||
} | ||
|
||
/** | ||
* Item factory method for easy injection in tests. | ||
*/ | ||
public function buildItem(string $hrefPath, string $label, ?string $iconAssetPath = null): Item | ||
{ | ||
return new Item($hrefPath, $label, $iconAssetPath); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace SimpleSAML\Module\oidc\Admin\Menu; | ||
|
||
class Item | ||
{ | ||
public function __construct( | ||
protected string $hrefPath, | ||
protected string $label, | ||
protected ?string $iconAssetPath = null, | ||
) { | ||
} | ||
|
||
public function getHrefPath(): string | ||
{ | ||
return $this->hrefPath; | ||
} | ||
|
||
public function getLabel(): string | ||
{ | ||
return $this->label; | ||
} | ||
|
||
public function getIconAssetPath(): ?string | ||
{ | ||
return $this->iconAssetPath; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace SimpleSAML\Module\oidc\Controller; | ||
|
||
use SimpleSAML\Module\oidc\Admin\Authorization; | ||
use SimpleSAML\Module\oidc\Factories\TemplateFactory; | ||
use SimpleSAML\Module\oidc\ModuleConfig; | ||
use Symfony\Component\HttpFoundation\Response; | ||
|
||
class AdminController | ||
{ | ||
public function __construct( | ||
protected readonly ModuleConfig $moduleConfig, | ||
protected readonly TemplateFactory $templateFactory, | ||
protected readonly Authorization $authorization, | ||
) { | ||
$this->authorization->requireSspAdmin(true); | ||
} | ||
|
||
public function configOverview(): Response | ||
{ | ||
return $this->templateFactory->render( | ||
'oidc:config/overview.twig', | ||
[ | ||
'moduleConfig' => $this->moduleConfig, | ||
], | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace SimpleSAML\Module\oidc\Exceptions; | ||
|
||
use SimpleSAML\Module\oidc\Exceptions\OidcException; | ||
|
||
class AuthorizationException extends OidcException | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.