19 Commits

Author SHA1 Message Date
923aeb970e Use a generic Protocol model for User instead of Pydantic 2022-04-29 13:49:21 +02:00
bce37a1116 Fix unit test following httpx-oauth update 2022-04-21 11:20:32 +02:00
c4de66b81c Revamp authentication (#831)
* Implement Transport classes

* Implement authentication strategy classes

* Revamp authentication with Transport and Strategy

* Revamp strategy and OAuth so that they can use a callable dependency

* Update docstring

* Make ErrorCode a proper Enum and cleanup unused OpenAPI utils

* Remove useless check

* Tweak typing in authenticator

* Update docs

* Improve logout/destroy token logic

* Update docs

* Update docs

* Update docs and full examples

* Apply formatting to examples

* Update OAuth doc and examples

* Add migration doc

* Implement Redis session token

* Add Redis Session documentation

* RedisSession -> Redis

* Fix links in docs
2021-12-30 15:22:07 +01:00
f578a01a8b Updated OAuth2 router generator for better OpenAPI docs (#793)
* Added OAuth2 authorize route response_model

* Changed OAuth2 "authorize" route backend param type.

On OAuth2 router creation, an enum is created for the `authentication_backend` parameter. This allows us to generate OpenAPI docs correctly.

* Reformatted with "make format"

* Updated OAuth2 authorize url docs

- /authorize now returns 422 instead of 400 for an invalid authentication backend
2021-11-10 07:55:40 +01:00
0c45cbc179 Add a name on every route #762 (#774)
* Names for urls added

* Tests for Login/Logout Names

* Register Name Test

* tests/test_router_reset.py

* Tests to verify url names in users router

* Test Verify Router Names

* oauth routes updated with prefix

* Test for authorize.  Didn't right test for callback as covered under other tests
2021-11-02 08:12:43 +01:00
3bdae94869 Refactor OAuth logic into manager 2021-09-15 11:57:17 +02:00
90aee2d487 Tweak unit tests 2021-09-14 11:30:41 +02:00
dade8c263d Revamp implementation with a manager layer and db class as dependency callable 2021-09-14 11:12:34 +02:00
7ae2042500 Fix #701: factorize JWT handling and support secrets as SecretStr 2021-09-09 11:51:55 +02:00
7cf7154e27 Fix #431: make OAuth expires_at optional in model and DB schemas 2020-12-28 08:59:27 +01:00
46b9d90ec4 Apply isort to test files 2020-10-14 14:12:04 +02:00
ad56933836 Bump dependencies 2020-10-14 14:11:51 +02:00
8adce74cd9 added samesite option for cookie authentication (#337)
* added samesite option for cookie authentication

* formatted with black and added documentation (grabbed from starlette.io documentation)
2020-09-30 07:27:25 +02:00
7721f8dcc1 Revamp authentication routes structure (#201)
* Fix #68: use makefun to generate dynamic dependencies

* Remove every Starlette imports

* Split every routers and remove event handlers

* Make users router optional

* Pass after_update handler to get_users_router

* Update documentation

* Remove test file

* Write migration doc for splitted routers
2020-05-24 10:18:01 +02:00
0a0dcadfdc Use real UUID for User id. and OAuthAccount id. (#198)
* Use UUID for user id and oauth account id

* Update documentation for UUID

* Tweak GUID definition of SQLAlchemy to match Tortoise ORM one

* Write migration doc
2020-05-21 16:40:33 +02:00
639217bb08 Make unit tests full async (#160)
* Bump pytest-asyncio from 0.10.0 to 0.11.0

Bumps [pytest-asyncio](https://github.com/pytest-dev/pytest-asyncio) from 0.10.0 to 0.11.0.
- [Release notes](https://github.com/pytest-dev/pytest-asyncio/releases)
- [Commits](https://github.com/pytest-dev/pytest-asyncio/compare/v0.10.0...v0.11.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

* Bump pytest-asyncio from 0.10.0 to 0.11.0

Bumps [pytest-asyncio](https://github.com/pytest-dev/pytest-asyncio) from 0.10.0 to 0.11.0.
- [Release notes](https://github.com/pytest-dev/pytest-asyncio/releases)
- [Commits](https://github.com/pytest-dev/pytest-asyncio/compare/v0.10.0...v0.11.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

* Convert tests to full async

* Change deprecated yield_fixture

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Co-authored-by: François Voron <fvoron@gmail.com>
2020-04-25 11:34:11 +02:00
325882436c Fix on_after_register handler not being passed Request with OAuth 2020-01-20 12:22:02 +01:00
fff167043a Fix authorize not using arbitrary redirect url 2020-01-17 16:18:49 +01:00
88b133d41c Implement OAuth2 flow (#88)
* Move users router in sub-module

* Factorize UserRouter into EventHandlersRouter

* Implement OAuth registration/login router

* Apply isort/black

* Remove temporary pytest marker

* Fix httpx-oauth version in lock file

* Ensure ON_AFTER_REGISTER event is triggered on OAuth registration

* Add API on FastAPIUsers to generate an OAuth router

* Improve test coverage of FastAPIUsers

* Small fixes

* Write the OAuth documentation

* Fix SQL unit-tests by avoiding collisions in SQLite db files
2020-01-17 11:43:17 +01:00