← PHP / Laravel · Contents

PHP-087 / Beginner

FormRequest authorize() defaults to true

A01:2021 Broken Access Control · CWE-862 Missing Authorization

Why is this a problem?

Leaving the generated default code unchanged allows anyone to submit the request.

How to fix it

php
public function authorize(): bool { return $this->user()->can('update', $this->route('post')); }

Further reading