281 Commits

Author SHA1 Message Date
a7b77cac73 Create a dedicated test environment and fix coverage/typing issues to support Pydantic V2 2023-07-12 10:54:51 +02:00
e17bb609ae Add compatibility layer for Pydantic V2 2023-07-12 10:44:22 +02:00
69f96c1f49 Bump version 11.0.0 → 12.0.0
Breaking changes
----------------

* Drop Python 3.7 support
2023-06-27 15:42:56 +02:00
0605920c21 Drop Python 3.7 support 2023-06-27 15:30:38 +02:00
b1bce5d765 Add AsyncIterator to the DependencyCallable type (#1235)
* add AsyncIterator to the DependencyCallable type

* fix linting issues
2023-06-23 10:38:00 +02:00
aa5ef9ff3b Bump version 10.4.2 → 11.0.0
Breaking changes
----------------

* Transport classes now always build full response objects instead of using the implicit FastAPI `Response` object.
    * If you were not implementing your own custom transport classes, you will have nothing to do.
    * If you implemented custom classes, you should adapt them so they return a `Response` object. [[Example](8959a12d56/fastapi_users/authentication/transport/bearer.py)]
* Cookie transport now returns a proper `204 No Content` response on logout, which should please OpenAPI Generators. Thanks @caniko 🎉

New features
------------

* `on_after_login` method now accepts `response` in argument, which is the `Response` object built by the transport. [[Documentation](https://fastapi-users.github.io/fastapi-users/latest/configuration/user-manager/#on_after_login)] Thanks @sorasful 🎉

Bug fixes
---------

* Fix #1166: add type hint to /users/{id} routes. Thanks @gegnew 🎉
* Fix `/verify` route returning `null` user ID with Beanie. Thanks @jankadel 🎉
2023-04-29 13:54:02 +02:00
8959a12d56 Update verify.py (#1200)
* Update verify.py

When using a schema setup as proposed in the documentation like: ReadUser, CreateUser, UpdateUser and BaseUser in the combination with MongoDB / Beanie, the verify() method will not "enforce" the `user_schema` but instead will return the `BaseUser` which will cause serialisation errors as such:

```
pydantic.error_wrappers.ValidationError: 1 validation error for ReadUser
response -> id
```
because the mapping between MongoDBs internal `_id` and the Pydantic `id` does not work.

* use `from_orm`
2023-04-29 10:21:01 +02:00
a63264c99e Fix #1166: add type hint to /users/{id} routes 2023-04-27 09:41:22 +02:00
8fd097cbc8 Revamp Transport so they always build a full Response object (#1049)
* Revamp Transport so they always build a full Response object

* Fix linting

* Add private methods to set cookies on CookieTransport

* Change on_after_login login_return parameter to response
2023-04-27 09:32:49 +02:00
4e426d6823 Add login_return to on_after_login method (#1187) 2023-04-14 16:10:22 +02:00
bcae3e53ba Bump version 10.4.1 → 10.4.2
Documentation
-------------

* Update documentation for Beanie.
2023-04-14 15:50:07 +02:00
525c1866a7 Bump version 10.4.0 → 10.4.1
Bug fixes & improvements
---------

* Fix #1172: missing `is_verified_by_default` argument on `get_oauth_router` method
* Bump dependencies:
    * `python-multipart ==0.0.6`
2023-03-15 13:48:37 +01:00
982acb13fb Fix typings 2023-03-15 13:42:57 +01:00
5561a528db Fix #1172: expose is_verified_by_default argument on FastAPIUsers.get_oauth_router 2023-03-15 13:33:52 +01:00
7fbab34f98 Bump version 10.3.0 → 10.4.0
New features
------------

* SQLAlchemy 2.0 support [[Documentation](https://fastapi-users.github.io/fastapi-users/10.4/configuration/databases/sqlalchemy/)]
    * If you need to stay on SQLAlchemy 1.4, you can pin this dependency: `fastapi-users-db-sqlalchemy<5.0.0`
* Allow to set `is_verified` flag to `True` by default after OAuth registration [[Documentation](https://fastapi-users.github.io/fastapi-users/10.4/configuration/oauth/#set-is_verified-to-true-by-default)]

Improvements
------------

* Bump dependencies
    * `httpx-oauth >=0.4,<0.12`
2023-02-13 17:48:26 +01:00
9b57fa2e73 Allow to set is_verified to True after OAuth callback 2023-02-13 17:42:31 +01:00
5c48283155 Update docs for SQLAlchemy 2.0 2023-02-13 17:28:49 +01:00
0e975c9b95 Bump version 10.2.1 → 10.3.0
Improvements
------------

* Ensure the reset password token can be used only once.
* Change JWT access token structure to use standard `sub` claim instead of `user_id`.
    * ⚠ Existing JWT will be invalidated
* Change verify and reset password tokens structure to use standard `sub` claim instead of `user_id`.
2023-01-16 11:48:32 +01:00
b18389439a Use "sub" claim instead of "user_id" for JWT, verify and reset password tokens 2023-01-16 11:44:42 +01:00
794133c4fe Ensure reset password token is single use 2023-01-16 11:38:49 +01:00
4daa263326 Fix typing 2023-01-16 10:20:23 +01:00
1104460533 Bump version 10.2.0 → 10.2.1
Improvements
------------

* Bump `httpx-oauth >=0.4,<0.11`
    * With `httpx-oauth >= 0.10`, the OAuth2 client may be not able to return an email address depending on the OAuth Provider. In this case, the error `OAUTH_NOT_AVAILABLE_EMAIL` is raised during `/callback`. [[Documentation](https://fastapi-users.github.io/fastapi-users/10.2/usage/routes/#get-callback)]
* Enable Python 3.11 support in CI
2022-11-04 09:47:33 +01:00
c91e7657db Update for httpx-oauth >= 0.10 where account_email can be None 2022-11-04 09:35:51 +01:00
31ea8e4bc2 Bump version 10.1.5 → 10.2.0
New features
------------

* Trigger custom logic after user login with `on_after_login`. [[Documentation]()] Thanks @antont 🎉

Improvements
------------

* Bump dependencies:
    * `email-validator >=1.1.0,<1.4`
    * `pyjwt[crypto] ==2.5.0`
* Use Hatch for environment and package management
2022-10-18 09:02:47 +02:00
c9186b5382 Fix typing of samesite paramater in CookieTransport 2022-10-18 08:36:01 +02:00
7ad5f8073d on_after_login hook (#1092)
* on_after_login minimal impl.

Questions: is the spot logical for after method? Is after the internal login call.
Would before_login be needed? Maybe not, as auth is the way to do pre-login things.

Added fastapi request as a param just in case, as other callbacks had it too.

Docs addition is missing.

* tried to complete the implementation, but the test with user_manager.on_after_login.called fails though

* move on_after_login tests to right place, to TestLogin. These ones pass.

TODO: check TestCallback

* on_after_login tests to TestCallback too, for oauth. Apparently test_redirect_url_router fires the callback too, I guess that's correct, am not using oauth myself.

* fix formatting with make format

* docs for on_after_login

Co-authored-by: Toni Alatalo <toni.alatalo@gmail.com>
2022-10-18 08:02:01 +02:00
c7053e4621 Bump version: 10.1.4 → 10.1.5 2022-08-11 13:23:49 +02:00
6bc29dd23a Bump version: 10.1.3 → 10.1.4 2022-07-25 10:26:28 +02:00
d661585238 Revert "Cookie transport must return empty json and not null in response.data on login (#1037)"
This reverts commit 77d0077503d9d6b4dd206e3fc643d96bc3c5834c.
2022-07-25 10:23:55 +02:00
e25b82c090 Bump version: 10.1.2 → 10.1.3 2022-07-23 07:56:58 +00:00
d7a1e3420c Fix #1043: Add a prefix to the generated key in RedisStrategy 2022-07-23 07:53:57 +00:00
184d3ed101 Bump version: 10.1.1 → 10.1.2 2022-07-22 16:07:46 +02:00
77d0077503 Cookie transport must return empty json and not null in response.data on login (#1037)
* Fix: LoginResponse is set to application/json, and should return response with status code 204 when body is empty.

The database backend login response is a cookie header with empty body. This causes issues when integrating the openapi schema into openapi-generator. Because the code generator expects the response to be a JSON when the status code isn't 204.

* Fix: Bump fastapi version to appropriate version for status code 204 handling.

* Build a full response for CookieTransport login_response

Co-authored-by: Can H. Tartanoglu <2947298-caniko@users.noreply.gitlab.com>
Co-authored-by: François Voron <fvoron@gmail.com>
2022-07-22 15:53:56 +02:00
f38a35ec56 Bump version: 10.1.0 → 10.1.1 2022-06-21 10:01:35 +02:00
6f5b2b1503 Fix get_oauth_associate_router import to make it optional 2022-06-21 09:58:33 +02:00
f5f4ea482e Bump version: 10.0.7 → 10.1.0 2022-06-21 08:04:17 +02:00
f4338ca3df Handle UserAlreadyExists error in oauth callback route 2022-06-20 16:55:58 +02:00
ce15284fe9 Implement a router to associate an OAuth account with an authenticated user 2022-06-20 14:44:25 +02:00
64d3996415 Add flag to enable/disable email association with OAuth 2022-06-20 13:46:47 +02:00
3bb3728261 add on delete hook (#1014)
Co-authored-by: Schwannden Kuo <schwannden@mobagel.com>
2022-06-20 13:26:02 +02:00
2a6128c9fc Bump version: 10.0.6 → 10.0.7 2022-06-07 08:49:15 +02:00
c5ac2b0e6e Use newer version of Redis dependency incorporating async support 2022-06-07 08:43:41 +02:00
b59fc794f3 Bump version: 10.0.5 → 10.0.6 2022-05-27 09:49:39 +02:00
8121ad0b8c Bump version: 10.0.4 → 10.0.5 2022-05-25 08:50:21 +02:00
1b6b58c0e0 Manually cast user to User schema in routes to avoid issue #1000 2022-05-25 08:27:46 +02:00
e8635d9132 Bump version: 10.0.3 → 10.0.4 2022-05-19 14:45:22 +02:00
2477fdffc1 Bump version: 10.0.2 → 10.0.3 2022-05-10 08:42:09 +02:00
d0d1a0dea1 Bump version: 10.0.1 → 10.0.2 2022-05-06 15:04:15 +02:00
c1ce87b4fe Set orm_mode on BaseUser schema 2022-05-06 14:56:49 +02:00
15ce3eaab6 Bump version: 10.0.0 → 10.0.1 2022-05-06 13:20:33 +02:00