Skip to content

Commit 2149db0

Browse files
committed
Clean up to bring it to final state and add refs
1 parent 63f0422 commit 2149db0

File tree

3 files changed

+35
-35
lines changed

3 files changed

+35
-35
lines changed

docs/integration/configuration.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,5 @@ Claims(
6464
identity=lambda user: f"{user.provider}:{user.id}",
6565
)
6666
```
67+
68+
Check out the [tutorial](/references/tutorials#claims-mapping) on claims mapping for a clearer understanding.

docs/integration/integration.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ also contains all attributes of the user received from a certain provider.
4343
### Callback
4444

4545
The `callback` is called with the [`Auth`](#auth-context) and [`User`](#user-context) arguments when the authentication
46-
succeeds. This can be used for migrating an external user into the system of the existing application. Apart from other
47-
OAuth2 solutions that force using their base user models, certain architectural designs, or a database from a limited
48-
set of choices, this kind of solution gives developers freedom.
46+
succeeds. This can be used for [user provisioning](/references/tutorials#user-provisioning). Apart from other OAuth2
47+
solutions that force using their base user models, certain architectural designs, or a database from a limited set of
48+
choices, this kind of solution gives developers freedom.
4949

5050
## Router
5151

docs/references/tutorials.md

Lines changed: 30 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@ outline: deep
44

55
# Tutorials
66

7-
This documentation section contains samples and tutorials on important topics of using the library. Look at
7+
This documentation section covers samples and tutorials on important topics of using the library. Look at
88
the [examples](https://github.com/pysnippet/fastapi-oauth2/tree/master/examples)
99
and [tests](https://github.com/pysnippet/fastapi-oauth2/tree/master/tests) directories of the repository for other
1010
use-case implementations. Feel free to open an [issue](https://github.com/pysnippet/fastapi-oauth2/issues/new/choose) or
1111
a [discussion](https://github.com/pysnippet/fastapi-oauth2/discussions/new/choose) if your question is not covered by
1212
the documentation.
1313

14-
## User authentication
14+
## Authentication
1515

16-
By following the [integration](/integration/integration) docs, for the basic authentication, you must already have
16+
By following the [integration](/integration/integration) docs, for the basic user authentication, you must already have
1717
generated the client ID and secret to configure your `OAuth2Middleware` with at least one client configuration.
1818

1919
1. Go to the developer console or settings of your OAuth2 identity provider and generate new client credentials.
@@ -28,31 +28,6 @@ generated the client ID and secret to configure your `OAuth2Middleware` with at
2828
Once the authentication is successful, the user will be redirected to the `redirect_uri` and the `request.user` will
2929
contain the user information obtained from the IDP.
3030

31-
## User provisioning
32-
33-
User provisioning refers to the process of creating, updating, and deleting user accounts within the OAuth2 IDP and
34-
synchronizing that information with your FastAPI application's database. There are two approaches to user provisioning
35-
and both require the user claims to be mapped properly for creating a new user or updating an existing one.
36-
37-
### Automatic provisioning
38-
39-
After successful authentication, you can automatically create a user in your application's database using the
40-
information obtained from the IDP. The user creation or update can be handled at the `callback` function of the
41-
[middleware](/integration/integration#oauth2middleware) as it is called when authentication succeeds.
42-
43-
### Manual provisioning
44-
45-
After successful authentication, redirect the user to a registration form where they can complete their profile. This
46-
approach is useful when there missing mandatory attributes in `request.user` for creating a user in your application's
47-
database. You need to define a route for provisioning and provide it as `redirect_uri`, so
48-
the [user context](/integration/integration#user-context) will be available for usage.
49-
50-
::: info NOTE
51-
In both scenarios, it is recommended to use the `identity` attribute for uniquely identifying the user from the
52-
database. So if the application uses or plans to use multiple IDPs, make sure to include the `provider` attribute when
53-
calculating the `identity` attribute.
54-
:::
55-
5631
## Claims mapping
5732

5833
The `Claims` class includes permanent attributes like `display_name`, `identity`, `picture`, and `email`. It also allows
@@ -88,8 +63,8 @@ Claims(
8863

8964
::: info NOTE
9065

91-
Not all IDPs provide the `first_name` and the `last_name` attributes already joined as in the example or the `email` as
92-
a list. So you are given the flexibility using transformer function to map the attributes as you want.
66+
Not all IDPs provide the `first_name` and the `last_name` attributes already joined as in the example above, or
67+
the email in a list. So you are given the flexibility using transformer function to map the attributes as you want.
9368

9469
```mermaid
9570
flowchart LR
@@ -102,9 +77,32 @@ flowchart LR
10277

10378
:::
10479

105-
## CSRF protection
80+
## User provisioning
81+
82+
User provisioning refers to the process of creating, updating, and deleting user accounts within the OAuth2 IDP and
83+
synchronizing that information with your FastAPI application's database. There are two approaches to user provisioning
84+
and both require the user claims to be mapped properly for creating a new user or updating an existing one.
85+
86+
### Automatic provisioning
87+
88+
After successful authentication, you can automatically create a user in your application's database using the
89+
information obtained from the IDP. The user creation or update can be handled at the `callback` function of the
90+
[middleware](/integration/integration#oauth2middleware) as it is called when authentication succeeds.
91+
92+
### Manual provisioning
10693

107-
## PKCE support
94+
After successful authentication, redirect the user to a registration form where they can complete their profile. This
95+
approach is useful when there missing mandatory attributes in `request.user` for creating a user in your application's
96+
database. You need to define a route for provisioning and provide it as `redirect_uri`, so
97+
the [user context](/integration/integration#user-context) will be available for usage.
98+
99+
::: info NOTE
100+
101+
In both scenarios, it is recommended to use the `identity` attribute for uniquely identifying the user from the
102+
database. So if the application uses or plans to use multiple IDPs, make sure to include the `provider` attribute when
103+
calculating the `identity` attribute.
104+
105+
:::
108106

109107
<style>
110108
.info {

0 commit comments

Comments
 (0)