← Back to Web app developers
See how it helps
Laravel authorization and validation
Enforces validated input, record permissions and tenant boundaries at Laravel's server-side entry points.
laravel-auth-validation
Team members using this skill
When is it useful?
Use when adding forms or endpoints that read or modify protected data.
What does it help you do?
- Uses Form Requests and explicitly allowed fields for model updates.
- Checks policies, scoped bindings and identity derived from trusted server context.
- Protects query construction and rendered output from untrusted input.
Try asking this
Secure our order update endpoint against foreign customer IDs, injected role fields and unauthorized nested records. Submit an otherwise valid update with a foreign nested address and an admin flag. Reject unauthorized changes before persistence and verify unchanged protected fields.
Detailed documentation
Read the skill’s original instructions, examples and checks in their authored language.
Show less
Laravel Authorization & Validation
Form Request validation and mass assignment
- Validate incoming input in dedicated
FormRequestclasses (rules(),authorize(), custom messages), following the project's rule format (array or pipe-delimited,Rule::enum(),Rule::exists()->where(...)scoped to the current tenant). - Pass only
$request->validated()or$request->safe()->only([...])tocreate(),update()orfill(). Never pass$request->all(),$request->input()or$request->except()into mass assignment. - Keep sensitive attributes (
role,is_admin,tenant_id,user_id,balance,status) out of$fillableor set them explicitly on the model from verified server context.
Policies, Gates and tenant isolation
- Enforce authorization on the server for every mutated or read resource via Policies (
$this->authorize(),Gate::authorize(),->can()route middleware). Never trusttenant_id,user_id, ownership or roles sent in the request payload. - Scope nested route model bindings with
->scopeBindings()so child records cannot be accessed across parent resources. - Never treat an Eloquent global scope alone as complete authorization: verify how tenant and user context are resolved in HTTP requests, CLI commands and queued jobs, and check Policies explicitly.
Query and output safety
- Never interpolate user input into
whereRaw(),selectRaw(),orderByRaw()orDB::raw(); always pass bindings (whereRaw('price > ?', [$min])) and whitelist column and direction names beforeorderBy(). - Keep Blade
{{ $value }}escaping; use{!! $html !!}only for sanitized, trusted HTML. Ensure@csrfandthrottle:rate limiters protect state-changing and auth routes.
Included files 2
LICENSE.txtSKILL.md
