38 Commits

Author SHA1 Message Date
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
c759bb6915 Extending generated OpenAPI docs (#799)
* Added login endpoint docs

* make format

* Changed login route into multiple examples.

* Added reset password router docs

* Updated /{id} routes for user

* Updated /me routes

* Fixed user already exists response description

* Updated the /register route

* Updated verify routes

* Updated oauth2 endpoints.

* Applied `make format`

* Renamed Authentication methods for getting their openapi schemas

- `get_login_responses_success` -> `get_openapi_login_responses_success`
- `get_logout_responses_success` -> `get_openapi_logout_responses_success`

* Fixed flake8 errors

* Not using `Final` to keep python37 compatibility

Co-authored-by: François Voron <fvoron@gmail.com>
2021-11-23 13:13:51 +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
c1a0dd5476 Fix broken links in documentation 2021-11-07 10:47:40 +01:00
843b197875 Reflect correct UserManager handlers in docs (#768) 2021-10-16 09:25:53 +02:00
e819bb0b65 Add get_enabled_backends advanced feature 2021-09-21 08:20:07 +02:00
fc59cf11ef Rework the documentation 2021-09-17 15:14:36 +02:00
b7ddf97127 Fix link in documentation 2021-09-09 13:36:52 +02:00
38b72ac197 Improve docs regarding getting current user 2021-09-09 12:15:46 +02:00
e59fb2c9b9 Return 403 instead of 401 when a user is known (#705)
* return 403 instead of 401 if user is known

* return 403 for unverified users

* updated docs
2021-09-04 18:11:48 +02:00
5267e605f4 Implement password validation mechanism (#632)
* Implement password validation mechanism

* Add invalid password reason

* Always pass user in password validator

* Add password validation documentation
2021-05-17 08:58:23 +02:00
5d6be87369 Fix #610: add LOGIN_USER_NOT_VERIFIED to login route documentation 2021-04-20 13:57:00 +02:00
d184d7e90c Fix #609: make behavior more consistent on request verify token
Now, it always returns 202 even if the user is already verified
2021-04-20 13:54:50 +02:00
9967053ae0 Fix typos, grammar and spelling mistakes in docs (#584) 2021-04-02 12:47:57 +02:00
4776117f10 Write the docs for new current_user dependency 2021-02-06 13:55:41 +01:00
9c113e30a2 Prepare docs for v5 release 2021-01-12 11:24:52 +01:00
373157c284 Finalize user activation feature (#439)
* Add routes for user activation (#403)

* Add routes for user activation

Generate a token after creating the user in register route, passing to `activation_callback`, if `activation_callback` supplied
Create new `/activate` route that will verify the token and activate the user
Add new error codes to `fastapi_users/router/common.py`
Update documentation
Add tests

Co-authored-by: Mark Todd <markpeter.todd@hotmail.co.uk>

* Rework routes for user activation

* Separate verification logic and token generation into `/fastapi_users/router/verify.py`, with per-route callbacks for custom behaviour

* Return register router to original state

* Added `is_verified` property to user models

* Added `requires_verification` argument to `get_users_router`and `get_auth_router`

* Additional dependencies added for verification in `fastapi_users/authentication/__init__.py`

* Update tests for new behaviour

* Update `README.md` to describe a workaround for possible problems during testing, by exceeding ulimit file descriptor limit

Co-authored-by: Mark Todd <markpeter.todd@hotmail.co.uk>

* Restored docs to original state.

* All other modifications reqested added

Kebab-case on request-verify-token
SECRET now used as test string
Other minor changes

Co-authored-by: Mark Todd <markpeter.todd@hotmail.co.uk>

* Embed token in body in verify route

* Reorganize checks in verify route and add unit test

* Ignore coverage on Protocol classes

* Tweak verify_user function to take full user in parameter

* Improve unit tests structure regarding parametrized test client

* Make after_verification_request optional to be more consistent with other routers

* Tweak status codes on verify routes

* Write documentation for verification feature

* Add not released warning on verify docs

Co-authored-by: Edd Salkield <edd@salkield.uk>
Co-authored-by: Mark Todd <markpeter.todd@hotmail.co.uk>
2021-01-12 10:44:42 +01:00
47f2991ee8 Fix #399: fix logout example in doc 2020-12-07 08:00:25 +01:00
435f29331a Fix #391: put user creation logic in a importable function 2020-11-22 09:57:03 +01:00
13ff31ed08 Fix #253 and #258: improve documentation 2020-07-20 16:27:43 +02:00
224a311792 fix "Authorization: Bearer Undefined" on Swagger (#213)
* fix "Authorization: Bearer Undefined" on Swagger

* updating pytest to recognize access_token

* fix pytest KeyError

* adding changes requested (add token_type to documentation and tests)

* fix documentation
2020-06-15 14:04:03 +02:00
9508768502 Add get_optional_* dependency callables 2020-05-25 08:13:42 +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
5ea85beb32 Fix default port in flow page 2020-04-25 14:35:13 +02:00
bf0c924501 Complete documentation with a flow page with curl examples 2020-04-25 14:32:08 +02:00
a9ee467518 Remove list endpoint and related methods 2020-04-25 11:46:20 +02:00
05b1df9a16 Implement logout route 2020-02-03 10:12:33 +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
49deb437a6 Fix #42: multiple authentication backends (#47)
* Revamp authentication to allow multiple backends

* Make router generate a login route for each backend

* Apply black

* Remove unused imports

* Complete docstrings

* Update documentation

* WIP add cookie auth

* Complete cookie auth unit tests

* Add documentation for cookie auth

* Fix cookie backend default name

* Don't make cookie return a Response
2019-12-04 13:32:49 +01:00
37b34e6d28 Add one more example for route dependency (#40)
* Add one more example for routing dependencie

* fix for more purity

* Delete f-string
2019-11-06 13:14:45 +01:00
658161518a Add error codes on routes (#34)
Fix #33
2019-10-31 10:10:53 +01:00
9b7ec58800 #21: Add superuser routes (#30)
* Add CRU superuser routes

* Add delete method on DB adapters

* Add superuser delete route

* Add superuser routes documentation

* Pass black formatter
2019-10-29 13:32:44 +01:00
7485f79fc5 Fix documentation internal links 2019-10-25 08:54:05 +02:00
e146e4bca4 Fix #13: add /me update route 2019-10-20 10:11:48 +02:00
1996ed69ea Fix #14: add /me route 2019-10-20 09:30:26 +02:00
5d4979f9a9 Fix #19: 201 status code on successful registration 2019-10-19 18:36:57 +02:00
a4171f8bea Fix #18: check for existing user on registration 2019-10-19 18:31:08 +02:00
a5618399a1 Fix #9: Write documentation (#16)
* Start to write documentation

* Add docs favicon

* Add routes documentation

* Add doc about dependency callables

* Add information about how to make authenticated calls
2019-10-19 18:16:08 +02:00