API Requests CheckRequestInterface - evansims/openfga-php GitHub Wiki

Interface for authorization check request specifications. This interface defines the contract for creating authorization check requests that determine whether a user has a specific relationship with an object. It's the core interface for implementing permission verification in applications.

Table of Contents


Namespace

OpenFGA\Requests


Source

View source code


Implements


Related Classes


Methods

getAuthorizationModel

public function getAuthorizationModel(): string

Get the authorization model ID to use for the check. This specifies which version of the authorization model should be used when evaluating the permission check. Using a specific model ID ensures consistent results.

View source


Returns

string — The authorization model ID for permission evaluation


getConsistency

public function getConsistency(): Consistency|null

Get the consistency level for the check operation. This determines the read consistency requirement for the check operation, allowing you to balance between read performance and data consistency based on your application's needs.

View source


Returns

Consistency | null — The consistency level, or null to use the default consistency setting


getContext

public function getContext(): object|null

Get additional context data for conditional evaluation. This provides contextual information that can be used in conditional expressions within the authorization model, enabling dynamic permission evaluation based on runtime data.

View source


Returns

object | null — The context object containing additional data for evaluation, or null if no context is provided


getContextualTuples

public function getContextualTuples(): TupleKeysInterface|null

Get additional tuples to consider during the check. These contextual tuples are temporarily added to the authorization data during evaluation, allowing you to test permission scenarios with hypothetical or pending relationship changes.

View source


Returns

TupleKeysInterface | null — Additional relationship tuples for evaluation, or null if none provided


getRequest

public function getRequest(StreamFactoryInterface $streamFactory): RequestContext

Build a request context for HTTP execution. Transforms the request object into a standardized HTTP request context that can be executed by the OpenFGA HTTP client. This method handles all aspects of request preparation including parameter serialization, URL construction, header configuration, and body stream creation. The method validates that all required parameters are present and properly formatted, serializes complex objects to JSON, constructs the appropriate API endpoint URL, and creates the necessary HTTP message body streams.

View source


Parameters

Name Type Description
$streamFactory StreamFactoryInterface PSR-7 stream factory for creating request body streams from serialized data

Returns

RequestContext — The prepared request context containing HTTP method, URL, headers, and body ready for execution


getStore

public function getStore(): string

Get the store ID containing the authorization data. This identifies which OpenFGA store contains the relationship tuples and configuration to use for the permission check.

View source


Returns

string — The store ID containing the authorization data


getTrace

public function getTrace(): bool|null

Get whether to include evaluation trace in the response. When enabled, the response will include detailed information about how the permission decision was reached, which is useful for debugging authorization logic.

View source


Returns

bool | null — Whether to include trace information, or null to use the default setting


getTupleKey

public function getTupleKey(): TupleKeyInterface

Get the relationship tuple to check for permission. This defines the specific relationship (user, object, relation) to evaluate for authorization. For example, checking if "user:alice" has "can_view" permission on "document:readme."

View source


Returns

TupleKeyInterface — The relationship tuple specifying what permission to check

⚠️ **GitHub.com Fallback** ⚠️