Skip to content

Commit 36d0961

Browse files
authored
Add URL generation and signed URL utilities (#16)
* Add URL generation and signed URL utilities This commit adds utility methods for generating URLs to stored files and creating cryptographically secure signed URLs for temporary access. Applications must implement their own serving controllers - this commit provides tools to make that easier without imposing architectural decisions. New features: - FileStorageTable::getUrl() - Generate URLs to serving endpoint - SignedUrlGenerator::generate() - Create signed URLs with expiration - SignedUrlGenerator::verify() - Verify signed URLs (timing-safe) - Comprehensive documentation in docs/Documentation/FileServing.md Configuration: ```php // config/app.php 'FileStorage' => [ 'serveRoute' => [ 'controller' => 'Files', 'action' => 'serve', ], 'signatureSecret' => env('FILE_STORAGE_SECRET'), ], ``` Documentation includes: - Complete serving controller examples - 5 authorization patterns (ownership, related entities, roles, etc.) - Security considerations (hotlinking, rate limiting, etc.) - Signed URL usage examples - Testing strategies Closes #XX * Fix PHPStan error in SignedUrlGenerator Cast signature to string for hash_equals to satisfy PHPStan type checking. * Fix coding standards * Fix CS * Remove getUrl() method - let applications handle URL generation Applications can easily generate URLs using Router::url() directly in their serving controller context where routing is properly configured. This reduces unnecessary abstraction and removes the assumption about routing structure.
1 parent d4e089e commit 36d0961

File tree

3 files changed

+1449
-0
lines changed

3 files changed

+1449
-0
lines changed

0 commit comments

Comments
 (0)