-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from djpugh/feature/user-klass-docs
- Loading branch information
Showing
23 changed files
with
299 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
Using fastapi_aad_auth | ||
********************** | ||
Please see `Basic Usage <usage>`_ for information on how to configure and setup ``fastapi_aad_auth``. | ||
|
||
Accessing User Tokens/View | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
There are two routes that are automatically added to this, the ``/me`` and ``/me/getToken`` routes. The ``/me`` route provides a summary of the current user, and enables them to get a bearer token from Azure AD. | ||
The ``/me/token`` endpoint provides that same token (for the logged in user) in a JSON object | ||
|
||
.. warning:: | ||
|
||
To get the token, this is primarily an interactive method, as it requires caching the token through the UI session based login approach, so it can fail intermittently depending on if the user has logged in recently. | ||
|
||
This can be disabled by setting the ``config.routing.user_path`` to ``None`` or ``''``. # | ||
|
||
Customising the User Model | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
The authentication state user can be processed within the application methods - the ``Depends`` part of the api route returns an | ||
:class:`~fastapi_aad_auth.oauth.state.AuthenticationState` object - ``auth_state`` in the ``testapp`` (see :ref:`testing`). | ||
|
||
.. literalinclude:: ../../tests/testapp/server.py | ||
:language: python | ||
:linenos: | ||
:start-at: @router.get('/hello') | ||
:end-at: return | ||
|
||
The associated user is then available at ``auth_state.user`` | ||
|
||
The :class:`~fastapi_aad_auth.oauth.aad.AADOAuthBackend` object takes a ``user_klass`` argument: | ||
|
||
.. literalinclude:: ../../src/fastapi_aad_auth/oauth/aad.py | ||
:language: python | ||
:linenos: | ||
:start-at: class AADOAuthBackend | ||
:end-before: """Initialise | ||
|
||
which defaults to the really basic :class:`~fastapi_aad_auth.oauth.state.User` class, but any object with the same | ||
interface should work, so you can add e.g. database calls etc. to validate/persist/check the user and any other | ||
desired behaviours. | ||
|
||
You can customise this when initialising the :class:`~fastapi_aad_auth.auth.AADAuth` object by setting | ||
the :class:`~fastapi_aad_auth.config.Config` ``user_klass`` variable (this can also be done by the | ||
associated environment variable):: | ||
|
||
from fastapi_aad_auth import AADAuth, Config | ||
|
||
config = Config() | ||
config.user_klass = MyUserClass | ||
|
||
auth = AADAuth(config) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,9 @@ | ||
Configuration Options | ||
********************* | ||
|
||
Many of the configuration options can be set using environment variables (or a ``.env`` file). | ||
|
||
.. contents:: Table of Contents | ||
:depth: 2 | ||
This section describes the overall configuration object and it's (nested) options, defined in: | ||
|
||
|
||
.. automodule:: fastapi_aad_auth.config | ||
:members: | ||
:exclude-members: bool_from_env,list_from_env | ||
.. autoconfig:: fastapi_aad_auth.config.Config | ||
:noindex: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
fastapi_aad_auth.auth | ||
********************* | ||
|
||
|
||
.. automodule:: fastapi_aad_auth.auth | ||
:members: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
fastapi_aad_auth.config | ||
*********************** | ||
|
||
.. automodule:: fastapi_aad_auth.config | ||
:members: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
fastapi_aad_auth.errors | ||
*********************** | ||
|
||
.. automodule:: fastapi_aad_auth.errors | ||
:members: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
fastapi_aad_auth.oauth._base | ||
**************************** | ||
|
||
.. automodule:: fastapi_aad_auth.oauth._base | ||
:members: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
fastapi_aad_auth.oauth.aad | ||
************************** | ||
|
||
.. automodule:: fastapi_aad_auth.oauth.aad | ||
:members: |
10 changes: 10 additions & 0 deletions
10
docs/source/module/fastapi_aad_auth.oauth.authenticators.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
fastapi_aad_auth.oauth.authenticators | ||
************************************* | ||
|
||
.. automodule:: fastapi_aad_auth.oauth.authenticators | ||
|
||
.. toctree:: | ||
:caption: Sub-modules: | ||
:maxdepth: 1 | ||
|
||
fastapi_aad_auth.oauth.authenticators.session |
5 changes: 5 additions & 0 deletions
5
docs/source/module/fastapi_aad_auth.oauth.authenticators.session.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
fastapi_aad_auth.oauth.authenticators.session | ||
********************************************* | ||
|
||
.. automodule:: fastapi_aad_auth.oauth.authenticators.session | ||
:members: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
fastapi_aad_auth.oauth | ||
********************** | ||
|
||
.. automodule:: fastapi_aad_auth.oauth | ||
|
||
.. toctree:: | ||
:caption: Sub-modules: | ||
:maxdepth: 1 | ||
|
||
fastapi_aad_auth.oauth._base | ||
fastapi_aad_auth.oauth.aad | ||
fastapi_aad_auth.oauth.authenticators | ||
fastapi_aad_auth.oauth.state | ||
fastapi_aad_auth.oauth.validators |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
fastapi_aad_auth.oauth.state | ||
**************************** | ||
|
||
.. automodule:: fastapi_aad_auth.oauth.state | ||
:members: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
fastapi_aad_auth.oauth.validators | ||
********************************* | ||
|
||
.. automodule:: fastapi_aad_auth.oauth.validators | ||
|
||
.. toctree:: | ||
:caption: Sub-modules: | ||
:maxdepth: 1 | ||
|
||
fastapi_aad_auth.oauth.validators.session | ||
fastapi_aad_auth.oauth.validators.token |
5 changes: 5 additions & 0 deletions
5
docs/source/module/fastapi_aad_auth.oauth.validators.session.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
fastapi_aad_auth.oauth.validators.session | ||
***************************************** | ||
|
||
.. automodule:: fastapi_aad_auth.oauth.validators.session | ||
:members: |
5 changes: 5 additions & 0 deletions
5
docs/source/module/fastapi_aad_auth.oauth.validators.token.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
fastapi_aad_auth.oauth.validators.token | ||
*************************************** | ||
|
||
.. automodule:: fastapi_aad_auth.oauth.validators.token | ||
:members: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
fastapi_aad_auth.ui | ||
******************* | ||
|
||
.. automodule:: fastapi_aad_auth.ui |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.