mirror of
https://github.com/fastapi-users/fastapi-users.git
synced 2026-03-13 07:49:55 +08:00
Expose more options for Cookie authentication
This commit is contained in:
@@ -18,9 +18,7 @@ auth_backends.append(cookie_authentication)
|
||||
|
||||
As you can see, instantiation is quite simple. You just have to define a constant `SECRET` which is used to encode the token and the lifetime of the cookie (in seconds).
|
||||
|
||||
You can optionally define the `cookie_name`. **Defaults to `fastapiusersauth`**.
|
||||
|
||||
You can also optionally define the `name` which will be used to generate its [`/login` route](../../usage/routes.md#post-loginname). **Defaults to `cookie`**.
|
||||
You can optionally define the `name` which will be used to generate its [`/login` route](../../usage/routes.md#post-loginname). **Defaults to `cookie`**.
|
||||
|
||||
```py
|
||||
cookie_authentication = CookieAuthentication(
|
||||
@@ -30,6 +28,14 @@ cookie_authentication = CookieAuthentication(
|
||||
)
|
||||
```
|
||||
|
||||
You can also define the parameters for the generated cookie:
|
||||
|
||||
* `cookie_name` (`fastapiusersauth`): Name of the cookie.
|
||||
* `cookie_path` (`/`): Cookie path.
|
||||
* `cookie_domain` (`None`): Cookie domain.
|
||||
* `cookie_secure` (`True`): Whether to only send the cookie to the server via SSL request.
|
||||
* `cookie_httponly` (`True`): Whether to prevent access to the cookie via JavaScript.
|
||||
|
||||
!!! tip
|
||||
The value of the cookie is actually a JWT. This authentication backend shares most of its logic with the [JWT](./jwt.md) one.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user