-
Notifications
You must be signed in to change notification settings - Fork 5
API Models TupleKey
Represents a relationship tuple key defining a connection between user, relation, and object. A TupleKey is the fundamental unit of authorization in OpenFGA, representing a specific relationship like "user:anne is reader of document:budget." It consists of three parts: user (who), relation (what type of access), and object (what resource), optionally with conditions for attribute-based access. Use this when creating, querying, or managing specific relationships in your authorization system.
Table of Contents
OpenFGA\Models
TupleKeyInterfaceJsonSerializableModelInterface
- TupleKeyInterface (interface)
- TupleKeys (collection)
| Name | Value | Description |
|---|---|---|
OPENAPI_MODEL |
TupleKey |
public function getCondition(): ?OpenFGA\Models\ConditionInterfaceGet the condition that constrains this relationship. Conditions enable dynamic authorization by allowing relationships to be conditional based on runtime context, such as time of day, resource attributes, or other factors. When a condition is present, the relationship is only valid when the condition evaluates to true.
ConditionInterface | null — The condition that must be satisfied for this relationship to be valid, or null for an unconditional relationship
public function getObject(): stringGet the object in this relationship tuple. The object represents the resource or entity that the permission or relationship applies to. For example, in "user:alice can view document:readme," the object would be "document:readme." Objects are typically formatted as "type:id" where type describes the kind of resource.
string — The object identifier
public function getRelation(): stringGet the relation that defines the type of relationship. The relation describes what kind of permission or relationship exists between the user and object. For example, common relations include "owner," "viewer," "editor," "can_read," "can_write." Relations are defined in your authorization model and determine what actions are permitted.
string — The relation name defining the type of relationship
public function getUser(): stringGet the user (subject) in this relationship tuple. The user represents the entity that has the relationship to the object. This can be an individual user, a group, a role, or any other subject defined in your authorization model. For example, in "user:alice can view document:readme," the user would be "user:alice."
string — The user identifier
public function jsonSerialize(): arraySerialize the tuple key for JSON encoding. This method prepares the tuple key data for API requests or storage, ensuring all components (user, relation, object, and optional condition) are properly formatted according to the OpenFGA API specification.
array — The serialized tuple key data ready for JSON encoding
Implements Models\TupleKeyInterface
public function schema(): SchemaInterfaceGet the schema definition for this model. This method returns the schema that defines the structure, validation rules, and serialization behavior for this model class. The schema is used for data validation, transformation, and ensuring consistency across API operations with the OpenFGA service. Each model's schema defines: - Required and optional properties - Data types and format constraints - Nested object relationships - Validation rules and business logic constraints The schema system enables the SDK to automatically validate incoming data, transform between different representations, and ensure compliance with the OpenFGA API specification.
SchemaInterface — The schema definition containing validation rules and property specifications for this model
Getting Started: Introduction • Installation • Authentication
Essentials: Stores • Authorization Models • Relationship Tuples • Permissions Queries
Features: Helper Functions • Concurrency • Results • Exceptions • Observability • Integration
- API Reference - Full class and method documentation
- Quickstart - Get up and running in minutes
- Helpers - Convenient shortcuts for common operations
- Testing Guide - Unit testing with the SDK
- Performance Guide - Optimize for high-scale applications
- Report Issues - Bug reports and feature requests
- Discussions - Community support and questions
- Contributing - Help improve the SDK
- Changelog - Latest updates and releases
- OpenFGA Documentation - Official OpenFGA documentation
- OpenFGA Playground - Interactive modeling environment
- Authorization Concepts - Learn relationship-based access control
- Other SDKs - JavaScript, Go, Python, .NET, and more
OpenFGA PHP SDK • Apache 2.0 License
- Authorization Stores
- Authorization Models
- Relationship Tuples
- Permission Queries
- Testing with Assertions
- Helper Functions
- Concurrency
- Error Handling
- Framework Integration
- OpenTelemetry Observability
- Result Pattern
- Event Dispatcher
- HTTP Request Sent Event
- HTTP Response Received Event
- Operation Started Event
- Operation Completed Event
- More Events …
- Authentication Exception
- Client Exception
- Configuration Exception
- Network Exception
- Serialization Exception
- More Exceptions …
- Request Manager
- Request Context
- Circuit Breaker
- Parallel Task Executor
- Fiber Concurrent Executor
- Simple Concurrent Executor
- Retry Handler
- Exponential Backoff Retry Strategy
- More Networking …