# 用户认证与授权

创建一个基本的用户认证系统-包括注册，登录，会话，密码重置，以及访问权限，常常是相对耗时的一件事。将这些功能抽取成库成了主要的任务，并且有很多这样的库。

但是，由于不同项目对身份验证的需求不同，大多数身份验证系统都变得笨重，很快就无法使用。值得庆幸的是，Laravel已经找到了一种方法，使认证系统易于使用和理解，但其灵活性足以适应各种场景。

每一个新安装的Laravel都有现成的create\_users\_table迁移和用户模型。Laravel提供一个Artisan make:auth命令用于填充认证集合和路由。每次安装都有RegisterController, 一个LoginController, 一个ForgotPasswordController, 和一个 ResetPasswordController。API干净清晰，各种约定协同工作，提供简单，无缝的身份验证和授权系统。

> 5.3之前Laravel的认证结构差异
>
> 请注意，在Laravel 5.1和5.2中，大多数功能都位于AuthController中；在5.3及更高版本中，此功能已拆分为多个控制器。我们将在这里介绍的关于如何自定义重定向路由、授权保护等的许多细节与5.1和5.2中有所不同（尽管所有核心功能都是相同的）。因此，如果您在5.1或5.2上，并且希望更改一些默认的身份验证行为，那么您可能需要深入了解AuthController，以了解您应该如何准确地自定义它。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://liseen315.gitbook.io/laravel/yong-hu-ren-zheng-yu-shou-quan.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
