feat: pemissions
Integration Tests / Integration Tests (pull_request) Successful in 52s

Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
2026-07-23 18:01:26 -04:00
parent e36a1dbfba
commit 3e921fc07e
6 changed files with 109 additions and 29 deletions
+3 -9
View File
@@ -53,7 +53,7 @@ class PasswordController extends ControllerAbstract
/**
* Admin endpoint: Get credential status for a user
*/
#[AuthenticatedRoute('/admin/status/{uid}', name: 'password.admin.status', methods: ['GET'])]
#[AuthenticatedRoute('/status', name: 'password.admin.status', methods: ['POST'], permissions: ['authentication_provider_password.admin.view', 'authentication_provider_password.admin.manage'])]
public function getStatus(string $uid): JsonResponse
{
$tenantId = $this->sessionTenant->identifier();
@@ -62,8 +62,6 @@ class PasswordController extends ControllerAbstract
return new JsonResponse(['error' => 'Invalid session state'], 400);
}
// TODO: Add permission check for admin operations
$user = $this->userAccountsService->fetchByIdentifier($uid);
if (!$user) {
return new JsonResponse(['error' => 'User not found'], 404);
@@ -81,7 +79,7 @@ class PasswordController extends ControllerAbstract
/**
* Admin endpoint: Set/reset user password
*/
#[AuthenticatedRoute('/admin/reset', name: 'password.admin.reset', methods: ['POST'])]
#[AuthenticatedRoute('/reset', name: 'password.admin.reset', methods: ['POST'], permissions: ['authentication_provider_password.admin.manage'])]
public function adminReset(string $uid, string $password): JsonResponse
{
$tenantId = $this->sessionTenant->identifier();
@@ -90,8 +88,6 @@ class PasswordController extends ControllerAbstract
return new JsonResponse(['error' => 'Invalid session state'], 400);
}
// TODO: Add permission check for admin operations
if (strlen($password) < 8) {
return new JsonResponse(['error' => 'Password must be at least 8 characters'], 400);
}
@@ -114,7 +110,7 @@ class PasswordController extends ControllerAbstract
/**
* Admin endpoint: Remove user password
*/
#[AuthenticatedRoute('/admin/remove/{uid}', name: 'password.admin.remove', methods: ['DELETE'])]
#[AuthenticatedRoute('/remove', name: 'password.admin.remove', methods: ['POST'], permissions: ['authentication_provider_password.admin.manage'])]
public function adminRemove(string $uid): JsonResponse
{
$tenantId = $this->sessionTenant->identifier();
@@ -123,8 +119,6 @@ class PasswordController extends ControllerAbstract
return new JsonResponse(['error' => 'Invalid session state'], 400);
}
// TODO: Add permission check for admin operations
$user = $this->userAccountsService->fetchByIdentifier($uid);
if (!$user) {
return new JsonResponse(['error' => 'User not found'], 404);
+10
View File
@@ -53,6 +53,16 @@ class Module extends ModuleInstanceAbstract implements ModuleConsoleInterface, M
'description' => 'View and access the password authentication provider module',
'group' => 'Authentication Providers'
],
'authentication_provider_password.admin.view' => [
'label' => 'View Password Status',
'description' => 'View whether another user has a password credential configured',
'group' => 'Authentication Providers'
],
'authentication_provider_password.admin.manage' => [
'label' => 'Manage User Passwords',
'description' => 'Set, reset, or remove password credentials for other users',
'group' => 'Authentication Providers'
],
];
}