{"enrichment":{"faq":[{"a":"Laravel-authorization-patterns teaches two complementary authorization mechanisms. Gates are simple, closure-based checks for general abilities (e.g., \"can edit posts\"), while Policies are classes that organize authorization logic for specific models. Gates work well for simple, application-wide permissions; Policies excel at model-specific rules like \"can user edit this post?\" Both integrate seamlessly with middleware, Blade directives, and the authorize() method.","q":"What are Laravel authorization patterns and how do Gates and Policies differ?"},{"a":"Laravel-authorization-patterns covers creating Policy classes that define methods matching your authorization needs (create, view, update, delete). You register Policies in your AuthServiceProvider, then use them via the authorize() method in controllers or form requests. Policies receive the authenticated user and the model instance, enabling fine-grained checks like verifying a user owns a post before allowing edits. The before() method can short-circuit checks for admins.","q":"How do you implement model-based authorization with Laravel Policies?"},{"a":"Laravel-authorization-patterns emphasizes checking authorization early: use middleware for route-level protection, call authorize() in controller methods or form requests for action-level checks, and employ Blade directives (@can, @cannot) in views for conditional rendering. This layered approach prevents unauthorized access at every level. Always validate in controllers and form requests, not just views, since views can be bypassed.","q":"What are the best practices for applying authorization checks in routes, controllers, and views?"},{"a":"Laravel-authorization-patterns includes testing strategies using Laravel's testing utilities. Write tests that verify authorized users can perform actions and unauthorized users receive denials. Test both Gates and Policies with different user roles and model states. Use actingAs() to simulate authenticated users, then assert that authorize() throws AuthorizationException or that responses reflect proper access denial.","q":"How do you test authorization logic and access control in Laravel?"},{"a":"Laravel-authorization-patterns covers middleware that checks authorization before reaching controllers. Middleware can verify Gates or Policies, rejecting unauthorized requests early. Configure it in your route definitions or middleware groups to enforce consistent access control across related routes. This prevents unauthorized users from ever reaching your business logic, improving security and reducing redundant checks.","q":"What does laravel authorization middleware do and how is it configured?"},{"a":"Laravel-authorization-patterns teaches using @can/@cannot directives to conditionally render form fields and buttons, preventing unauthorized users from seeing restricted actions. Authorization Response objects provide detailed denial messages beyond simple true/false, enabling custom error feedback. Combine these with form request authorization to validate permissions server-side, ensuring no unauthorized data reaches your database.","q":"How do Blade directives and authorization response objects secure forms and requests?"}],"shadow_tags":["access-control","permission-system","role-based-auth","policy-pattern","middleware-auth","blade-templating","form-validation-auth","testing-security","authorization-response"],"summary_rewrite":"Learn to implement authorization in Laravel using Gates for general ability checks and Policies for model-specific access rules. This skill covers middleware integration, Blade directives for conditional rendering, and Response objects for detailed permission messages. Includes testing strategies and best practices for securing controllers and form requests."},"files":[{"bytes":6936,"path":"skills/laravel-authorization-patterns/SKILL.md","sha256":"f39c8be517bff078cc1bce86cfedcf6367fc54cb8730b880355e52de46ac94bb","url":"https://skillfed.io/files/iSerter/laravel-claude-agents/laravel-authorization-patterns/ff1f57d4/SKILL.md"}],"id":"iSerter/laravel-claude-agents/laravel-authorization-patterns","links":{"html":"https://skillfed.io/iSerter/laravel-claude-agents/laravel-authorization-patterns","md":"https://skillfed.io/iSerter/laravel-claude-agents/laravel-authorization-patterns.md","repo":"https://github.com/iSerter/laravel-claude-agents"},"meta":{"agents_supported":[],"first_seen":"2026-07-28","forks":8,"language":"PHP","last_updated":"2026-04-19","license":"MIT","name":"laravel-authorization-patterns","publisher":"iSerter","stars":41},"relations":{"similar":[{"id":"affaan-m/ECC/laravel-security"},{"id":"personamanagmentlayer/pcl/php-expert"},{"id":"Jeffallan/claude-skills/laravel-specialist"},{"id":"rawveg/skillsforge-marketplace/laravel"},{"id":"noartem/skills/laravel-policies-and-authorization"},{"id":"iSerter/laravel-claude-agents/laravel-tdd"},{"id":"AsyrafHussin/agent-skills/laravel-best-practices"},{"id":"affaan-m/ECC/laravel-tdd"},{"id":"iSerter/laravel-claude-agents/eloquent-best-practices"},{"id":"iSerter/laravel-claude-agents/laravel-notification-patterns"}]},"slug":{"owner":"iSerter","repo":"laravel-claude-agents","skill":"laravel-authorization-patterns"},"version":"ff1f57d4"}
