final class ApiKeyScope (View source)

Immutable description of what an API key is allowed to do.

A key with no restrictions ({\Poweradmin\Domain\Model\self::unrestricted()}) behaves exactly like a pre-scope key: every zone and every operation is permitted. Restrictions are additive guards layered on top of the creating user's own permissions - they can only narrow access, never widen it.

Constants

OP_VIEW

OP_CREATE

OP_UPDATE

OP_DELETE

OPERATIONS

Methods

__construct(array|null $zoneIds, array|null $operations, bool $isReadonly)

No description

static ApiKeyScope
unrestricted()

A scope that permits everything (the implicit scope of a key with no restrictions).

static string
methodToOperation(string $method)

Map an HTTP method to the operation it represents.

bool
isOperationAllowed(string $method)

Whether the operation behind the given HTTP method is allowed by this scope.

bool
isOperationTypeAllowed(string $operation)

Whether a specific operation (view/create/update/delete) is allowed by this scope. Use this for endpoints where the HTTP method does not determine the operation - e.g. bulk record changes or dynamic DNS upserts.

bool
isZoneAllowed(int $zoneId)

Whether the given zone is within this scope.

bool
hasZoneRestriction()

No description

array|null
getZoneIds()

No description

array|null
getOperations()

No description

bool
isReadonly()

No description

Details

__construct(array|null $zoneIds, array|null $operations, bool $isReadonly)

No description

Parameters

array|null $zoneIds

Zones the key may touch; null means no zone restriction

array|null $operations

Operations the key may perform; null means all

bool $isReadonly

When true, only view (GET) requests are allowed

static ApiKeyScope unrestricted()

A scope that permits everything (the implicit scope of a key with no restrictions).

Return Value

ApiKeyScope

static string methodToOperation(string $method)

Map an HTTP method to the operation it represents.

Parameters

string $method

Return Value

string

bool isOperationAllowed(string $method)

Whether the operation behind the given HTTP method is allowed by this scope.

Convenience wrapper for endpoints whose HTTP method maps directly to one operation; mixed-action endpoints should call {\Poweradmin\Domain\Model\self::isOperationTypeAllowed()}.

Parameters

string $method

Return Value

bool

bool isOperationTypeAllowed(string $operation)

Whether a specific operation (view/create/update/delete) is allowed by this scope. Use this for endpoints where the HTTP method does not determine the operation - e.g. bulk record changes or dynamic DNS upserts.

Parameters

string $operation

Return Value

bool

bool isZoneAllowed(int $zoneId)

Whether the given zone is within this scope.

Parameters

int $zoneId

Return Value

bool

bool hasZoneRestriction()

No description

Return Value

bool

array|null getZoneIds()

No description

Return Value

array|null

array|null getOperations()

No description

Return Value

array|null

bool isReadonly()

No description

Return Value

bool