Skip to content

Commit 960c319

Browse files
committed
Check if permissions are enabled before enforcing them
1 parent d84595d commit 960c319

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

src/Services/AuthContextService.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,6 @@ public function __construct(
3131
) {
3232
}
3333

34-
public function isSspAdmin(): bool
35-
{
36-
return $this->sspBridge->utils()->auth()->isAdmin();
37-
}
38-
3934
/**
4035
* @throws \SimpleSAML\Error\Exception
4136
* @throws \Exception
@@ -57,8 +52,6 @@ public function getAuthUserId(): string
5752
*/
5853
public function requirePermission(string $neededPermission): void
5954
{
60-
$auth = $this->authenticate();
61-
6255
$permissions = $this->moduleConfig
6356
->config()
6457
->getOptionalConfigItem(ModuleConfig::OPTION_ADMIN_UI_PERMISSIONS, null);
@@ -69,6 +62,9 @@ public function requirePermission(string $neededPermission): void
6962
if (!$permissions->hasValue($neededPermission)) {
7063
throw new RuntimeException('No permission defined for ' . $neededPermission);
7164
}
65+
66+
$auth = $this->authenticate();
67+
7268
$attributeName = $permissions->getString('attribute');
7369
/** @var string[] $entitlements */
7470
$entitlements = $auth->getAttributes()[$attributeName] ?? [];

0 commit comments

Comments
 (0)