# 守卫

Laravel认证系统通过一个叫守卫的东西进行路由。每个守卫都包含两部分：定义如何持久化并检索身份验证状态的驱动程序（例如，会话），以及允许您按特定条件获取用户的程序（例如，用户）

开箱即用，Laravel有两个守卫：web和api。 web是更传统的身份验证方式，使用会话驱动程序和基本用户提供程序。 api使用相同的用户提供程序，但它使用令牌驱动程序而不是会话来验证每个请求。

如果你想以不用的方式处理认证跟持久化(例如更改长会话为token)你需要更改驱动程序，如果想要更改存储类型或者检索方法,你需要更改提供程序，例如将用户存储从mysql迁移到mongo


---

# 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/shou-wei.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.
