mirror of
https://github.com/shlinkio/shlink.git
synced 2026-03-12 01:54:41 +08:00
Implemented mechanism to add/remove roles from API keys
This commit is contained in:
39
module/Rest/src/ApiKey/Model/RoleDefinition.php
Normal file
39
module/Rest/src/ApiKey/Model/RoleDefinition.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Shlinkio\Shlink\Rest\ApiKey\Model;
|
||||
|
||||
use Shlinkio\Shlink\Rest\ApiKey\Role;
|
||||
|
||||
final class RoleDefinition
|
||||
{
|
||||
private string $roleName;
|
||||
private array $meta;
|
||||
|
||||
private function __construct(string $roleName, array $meta)
|
||||
{
|
||||
$this->roleName = $roleName;
|
||||
$this->meta = $meta;
|
||||
}
|
||||
|
||||
public static function forAuthoredShortUrls(): self
|
||||
{
|
||||
return new self(Role::AUTHORED_SHORT_URLS, []);
|
||||
}
|
||||
|
||||
public static function forDomain(string $domainId): self
|
||||
{
|
||||
return new self(Role::DOMAIN_SPECIFIC, ['domain_id' => $domainId]);
|
||||
}
|
||||
|
||||
public function roleName(): string
|
||||
{
|
||||
return $this->roleName;
|
||||
}
|
||||
|
||||
public function meta(): array
|
||||
{
|
||||
return $this->meta;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user