-
-
Notifications
You must be signed in to change notification settings - Fork 223
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FEATURE: Content Repository Privileges
Related: #3732
- Loading branch information
1 parent
2a8b490
commit 49aa8bb
Showing
30 changed files
with
426 additions
and
196 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
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
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
20 changes: 20 additions & 0 deletions
20
Neos.ContentRepository.Core/Classes/SharedModel/Auth/AuthProviderInterface.php
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,20 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Neos\ContentRepository\Core\SharedModel\Auth; | ||
|
||
use Neos\ContentRepository\Core\CommandHandler\CommandInterface; | ||
use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName; | ||
|
||
/** | ||
* @internal except for CR factory implementations | ||
*/ | ||
interface AuthProviderInterface | ||
{ | ||
public function getUserId(): UserId; | ||
|
||
public function getWorkspacePrivilege(WorkspaceName $workspaceName, WorkspacePrivilegeType $privilegeType): Privilege; | ||
|
||
public function getCommandPrivilege(CommandInterface $command): Privilege; | ||
} |
38 changes: 38 additions & 0 deletions
38
Neos.ContentRepository.Core/Classes/SharedModel/Auth/Privilege.php
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,38 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Neos.ContentRepository package. | ||
* | ||
* (c) Contributors of the Neos Project - www.neos.io | ||
* | ||
* This package is Open Source Software. For the full copyright and license | ||
* information, please view the LICENSE file which was distributed with this | ||
* source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Neos\ContentRepository\Core\SharedModel\Auth; | ||
|
||
/** | ||
* A privilege that is returned by the {@see AuthProviderInterface} | ||
* @api | ||
*/ | ||
final readonly class Privilege | ||
{ | ||
private function __construct( | ||
public bool $granted, | ||
public ?string $message, | ||
) { | ||
} | ||
|
||
public static function granted(): self | ||
{ | ||
return new self(true, null); | ||
} | ||
|
||
public static function denied(string $message): self | ||
{ | ||
return new self(false, $message); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
Neos.ContentRepository.Core/Classes/SharedModel/Auth/StaticAuthProvider.php
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,36 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Neos\ContentRepository\Core\SharedModel\Auth; | ||
|
||
use Neos\ContentRepository\Core\CommandHandler\CommandInterface; | ||
use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName; | ||
|
||
/** | ||
* A simple auth provider that just statically returns the same user id that it was given upon construction time and grants all privileges | ||
* | ||
* @api | ||
*/ | ||
final class StaticAuthProvider implements AuthProviderInterface | ||
{ | ||
public function __construct( | ||
private readonly UserId $userId, | ||
) { | ||
} | ||
|
||
public function getUserId(): UserId | ||
{ | ||
return $this->userId; | ||
} | ||
|
||
public function getWorkspacePrivilege(WorkspaceName $workspaceName, WorkspacePrivilegeType $privilegeType): Privilege | ||
{ | ||
return Privilege::granted(); | ||
} | ||
|
||
public function getCommandPrivilege(CommandInterface $command): Privilege | ||
{ | ||
return Privilege::granted(); | ||
} | ||
} |
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
23 changes: 23 additions & 0 deletions
23
Neos.ContentRepository.Core/Classes/SharedModel/Auth/WorkspacePrivilegeType.php
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,23 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Neos.ContentRepository package. | ||
* | ||
* (c) Contributors of the Neos Project - www.neos.io | ||
* | ||
* This package is Open Source Software. For the full copyright and license | ||
* information, please view the LICENSE file which was distributed with this | ||
* source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Neos\ContentRepository\Core\SharedModel\Auth; | ||
|
||
/** | ||
* @api | ||
*/ | ||
enum WorkspacePrivilegeType | ||
{ | ||
case READ_NODES; | ||
} |
23 changes: 0 additions & 23 deletions
23
Neos.ContentRepository.Core/Classes/SharedModel/User/StaticUserIdProvider.php
This file was deleted.
Oops, something went wrong.
13 changes: 0 additions & 13 deletions
13
Neos.ContentRepository.Core/Classes/SharedModel/User/UserIdProviderInterface.php
This file was deleted.
Oops, something went wrong.
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.