|
1 | 1 | # Changelog |
2 | 2 |
|
| 3 | +All notable changes to this project will be documented in this file. |
| 4 | + |
| 5 | +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), |
| 6 | +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). |
| 7 | + |
3 | 8 | ## [Unreleased] |
4 | 9 |
|
| 10 | +## [1.0.0] - 2025-01-05 |
| 11 | + |
5 | 12 | ### Added |
6 | 13 |
|
| 14 | +#### Core Features |
| 15 | +- **OpenFGA Integration**: Complete integration with OpenFGA for fine-grained authorization in Laravel applications |
| 16 | +- **Multi-connection Support**: Configure and use multiple OpenFGA instances simultaneously |
| 17 | +- **Eloquent Model Integration**: `HasAuthorization` trait for seamless model-based permissions |
| 18 | +- **Middleware Protection**: Route middleware for declarative authorization (`openfga`, `openfga.any`, `openfga.all`) |
| 19 | +- **Blade Directives**: Authorization directives for view-level access control (`@can`, `@cannot`, `@canany`) |
| 20 | +- **Artisan Commands**: CLI commands for managing permissions and debugging authorization |
| 21 | +- **Queue Integration**: Asynchronous permission operations with Laravel's queue system |
| 22 | +- **Advanced Caching**: Multi-tier caching with WriteBehindCache for performance optimization |
| 23 | +- **OpenTelemetry Support**: Built-in observability with OpenTelemetry integration |
| 24 | + |
7 | 25 | #### Type Safety Enhancements |
8 | | -- **Strict typing throughout codebase**: All PHP files now use `declare(strict_types=1)` for enhanced type safety |
9 | | -- **Comprehensive generic annotations**: Added detailed PHPDoc type annotations with generics for arrays, collections, and return types |
10 | | -- **DTO (Data Transfer Object) pattern**: Introduced `PermissionCheckRequest` DTO to replace associative arrays, providing better type safety and structure |
| 26 | +- **Strict typing throughout codebase**: All PHP files use `declare(strict_types=1)` for enhanced type safety |
| 27 | +- **Comprehensive generic annotations**: Detailed PHPDoc type annotations with generics for arrays, collections, and return types |
| 28 | +- **DTO (Data Transfer Object) pattern**: Introduced `PermissionCheckRequest` DTO for better type safety and structure |
11 | 29 | - **Interface contracts**: Enhanced interfaces with strict type declarations and comprehensive documentation |
12 | 30 |
|
13 | 31 | #### PHP 8.3+ Features |
|
19 | 37 | #### Developer Experience |
20 | 38 | - **Enhanced IDE support**: Comprehensive PHPDoc annotations enable better autocomplete and static analysis |
21 | 39 | - **Type-safe method chaining**: Fluent APIs with proper return type annotations |
22 | | -- **Strict parameter validation**: Runtime type checking combined with static analysis |
23 | | -- **Exception handling improvements**: Type-safe error handling with proper exception hierarchies |
24 | | - |
25 | | -### Enhanced |
26 | | - |
27 | | -#### Core Components |
28 | | -- **OpenFgaManager**: Added strict typing for all manager operations with comprehensive generics |
29 | | -- **Authorization Gate**: Enhanced gate implementation with template types and strict checking |
30 | | -- **Model Traits**: Improved HasAuthorization trait with type-safe method signatures |
31 | | -- **Cache Layer**: Type-safe caching implementation with proper key typing |
32 | | - |
33 | | -#### API Signatures |
34 | | -```php |
35 | | -/** |
36 | | - * Batch check multiple permissions at once. |
37 | | - * |
38 | | - * @param array<int, array{user: string, relation: string, object: string}> $checks |
39 | | - * @param string|null $connection Optional connection name |
40 | | - * @return array<string, bool> Keyed by "user:relation:object" |
41 | | - */ |
42 | | -public function batchCheck(array $checks, ?string $connection = null): array |
43 | | - |
44 | | -/** |
45 | | - * Check if a user has a specific permission. |
46 | | - * |
47 | | - * @param string $user |
48 | | - * @param string $relation |
49 | | - * @param string $object |
50 | | - * @param array<array{user: string, relation: string, object: string}|TupleKey> $contextualTuples |
51 | | - * @param array<string, mixed> $context |
52 | | - * @param string|null $connection |
53 | | - */ |
54 | | -public function check( |
55 | | - string $user, |
56 | | - string $relation, |
57 | | - string $object, |
58 | | - array $contextualTuples = [], |
59 | | - array $context = [], |
60 | | - ?string $connection = null, |
61 | | -): bool |
62 | | -``` |
63 | | - |
64 | | -#### Model Integration |
65 | | -```php |
66 | | -/** |
67 | | - * Grant multiple permissions to multiple users. |
68 | | - * |
69 | | - * @param array<int|Model|string> $users The users to grant permissions to |
70 | | - * @param array<string>|string $relations The relations/permissions to grant |
71 | | - */ |
72 | | -public function grantMany(array $users, array|string $relations): bool |
73 | | - |
74 | | -/** |
75 | | - * Get all relations a user has with this model. |
76 | | - * |
77 | | - * @param int|Model|string $user The user to check |
78 | | - * @param array<string> $relations Optional relation filters |
79 | | - * @return array<string, bool> |
80 | | - */ |
81 | | -public function getUserRelations($user, array $relations = []): array |
82 | | -``` |
83 | | - |
84 | | -### Technical Improvements |
85 | | - |
86 | | -#### Static Analysis |
87 | | -- **PHPStan Level 8**: Configured for maximum static analysis strictness |
88 | | -- **Psalm integration**: Added comprehensive type checking with Psalm |
89 | | -- **Rector support**: Automated code quality improvements and PHP version compliance |
90 | | -- **PHP-CS-Fixer**: Enforced consistent coding standards |
91 | | - |
92 | | -#### Testing Enhancements |
93 | | -- **Type-safe test utilities**: Enhanced testing framework with proper type annotations |
94 | | -- **Mock improvements**: Better type safety in test doubles and fakes |
95 | | -- **Assertion helpers**: Type-safe assertion methods for authorization testing |
96 | | - |
97 | | -### Breaking Changes |
98 | | - |
99 | | -**None Expected** - All type safety improvements are backward compatible. Existing code will continue to work without modification. |
100 | | - |
101 | | -### Migration Notes |
102 | | - |
103 | | -While no breaking changes are expected, developers can benefit from the enhanced type safety by: |
| 40 | +- **Comprehensive Example Application**: Full-featured example app demonstrating best practices |
| 41 | +- **Testing Utilities**: `FakesOpenFga` trait and test helpers for easy testing |
| 42 | +- **Docker Integration**: Optimized Docker setup for integration testing |
104 | 43 |
|
105 | | -1. **Enabling strict typing in your models**: |
106 | | - ```php |
107 | | - <?php |
| 44 | +#### Documentation |
| 45 | +- **Complete API documentation**: All public methods fully documented with type information |
| 46 | +- **Example application**: Comprehensive example showing real-world usage patterns |
| 47 | +- **Migration guides**: Clear instructions for integrating into existing applications |
| 48 | +- **Best practices guide**: Authorization patterns and performance optimization tips |
108 | 49 |
|
109 | | - declare(strict_types=1); |
| 50 | +### Technical Details |
110 | 51 |
|
111 | | - namespace App\Models; |
112 | | - |
113 | | - use OpenFGA\Laravel\Traits\HasAuthorization; |
114 | | - ``` |
115 | | - |
116 | | -2. **Using the new DTO pattern**: |
117 | | - ```php |
118 | | - use OpenFGA\Laravel\DTOs\PermissionCheckRequest; |
119 | | - |
120 | | - $request = PermissionCheckRequest::fromUser( |
121 | | - user: $user, |
122 | | - relation: 'editor', |
123 | | - object: 'document:123' |
124 | | - ); |
125 | | - ``` |
126 | | - |
127 | | -3. **Leveraging enhanced type hints**: |
128 | | - ```php |
129 | | - /** @var array<string, bool> $permissions */ |
130 | | - $permissions = $model->getUserRelations($user, ['editor', 'viewer']); |
131 | | - ``` |
132 | | - |
133 | | -### Performance Improvements |
134 | | - |
135 | | -- **Reduced runtime type checking overhead** through compile-time guarantees |
136 | | -- **Better opcode optimization** via strict type declarations |
137 | | -- **Enhanced caching efficiency** with type-safe cache keys |
138 | | - |
139 | | ---- |
140 | | - |
141 | | -## [1.0.0] - Initial Release |
142 | | - |
143 | | -### Added |
144 | | -- Core OpenFGA integration for Laravel |
145 | | -- Multi-connection support |
146 | | -- Eloquent model integration with HasAuthorization trait |
147 | | -- Middleware for route protection |
148 | | -- Blade directives for view-level authorization |
149 | | -- Comprehensive testing utilities |
150 | | -- Artisan commands for CLI management |
151 | | -- Advanced caching and queue support |
152 | | -- Complete documentation |
| 52 | +#### Static Analysis |
| 53 | +- **PHPStan Level 2**: Configured for robust static analysis |
| 54 | +- **Psalm Level 6**: Type checking with Psalm for additional safety |
| 55 | +- **Rector support**: Automated code quality improvements and PHP version compliance |
| 56 | +- **PHP-CS-Fixer**: Enforced PSR-12 coding standards |
| 57 | + |
| 58 | +#### Testing |
| 59 | +- **Unit Tests**: Comprehensive unit test coverage with Pest PHP |
| 60 | +- **Integration Tests**: Full integration test suite with real OpenFGA instance |
| 61 | +- **Example Tests**: Complete test suite for the example application |
| 62 | +- **GitHub Actions**: Automated CI/CD pipeline for quality assurance |
| 63 | + |
| 64 | +#### Performance |
| 65 | +- **Efficient caching strategies**: Multi-tier caching with write-behind optimization |
| 66 | +- **Batch operations**: Support for batch permission checks and writes |
| 67 | +- **Connection pooling**: Efficient HTTP client management |
| 68 | +- **Lazy loading**: Deferred service provider for faster boot times |
| 69 | + |
| 70 | +### Security |
| 71 | +- **Secure by default**: No credentials in code, environment-based configuration |
| 72 | +- **Input validation**: Comprehensive validation of all authorization inputs |
| 73 | +- **Error handling**: Graceful degradation with proper error messages |
| 74 | + |
| 75 | +### Compatibility |
| 76 | +- **Laravel**: 11.x and 12.x |
| 77 | +- **PHP**: 8.3+ |
| 78 | +- **OpenFGA**: 1.x |
| 79 | +- **PSR Standards**: PSR-4, PSR-12 compliant |
153 | 80 |
|
154 | 81 | [Unreleased]: https://github.com/evansims/openfga-laravel/compare/v1.0.0...HEAD |
155 | 82 | [1.0.0]: https://github.com/evansims/openfga-laravel/releases/tag/v1.0.0 |
0 commit comments