Welcome to the OpenFGA Laravel Cookbook! This section provides practical recipes and real-world examples to help you implement common authorization patterns with OpenFGA Laravel.
Learn how to implement traditional role-based access control where users are assigned roles and roles have permissions. This recipe covers:
- Setting up role hierarchies
- Managing user-role assignments
- Role-based route protection
- Conditional and temporary roles
- Testing RBAC implementations
Use this when: You need a traditional role-based system with clear role definitions and hierarchies.
Implement complex organizational structures with teams, departments, and nested permissions. This recipe demonstrates:
- Multi-level organizational hierarchies
- Team membership with inheritance
- Cross-organization collaboration
- Department-based access control
- Contextual access controls
Use this when: You're building multi-tenant applications with complex organizational structures.
We're working on additional recipes to cover more authorization patterns:
- Resource-Based Permissions: Document ownership with sharing capabilities
- Attribute-Based Access Control (ABAC): Context-aware permissions based on attributes
- Time-Based Access Control: Temporary permissions and scheduled access
- Geographic Access Control: Location-based permission restrictions
- API Security Patterns: Securing REST APIs and GraphQL endpoints
- Multi-Application SSO: Sharing permissions across multiple applications
Each recipe follows this structure:
- Authorization Model: The OpenFGA model definition
- Core Implementation: PHP classes and services
- Eloquent Integration: Laravel model integration
- API Endpoints: REST API examples
- Testing: Comprehensive test examples
- Best Practices: Performance and security considerations
Have a common authorization pattern you'd like to share? We welcome contributions! Please:
- Follow the existing recipe structure
- Include complete, working examples
- Add comprehensive tests
- Document any trade-offs or limitations
- Submit a pull request
- Check the main documentation for basic concepts
- Review the API Reference for detailed method documentation
- See the Troubleshooting Guide for common issues
- Visit our GitHub repository for support
Tip: Start with the RBAC recipe if you're new to OpenFGA Laravel - it covers the fundamental concepts that apply to all other patterns.