@@ -4,16 +4,16 @@ outline: deep
4
4
5
5
# Tutorials
6
6
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
8
8
the [ examples] ( https://github.com/pysnippet/fastapi-oauth2/tree/master/examples )
9
9
and [ tests] ( https://github.com/pysnippet/fastapi-oauth2/tree/master/tests ) directories of the repository for other
10
10
use-case implementations. Feel free to open an [ issue] ( https://github.com/pysnippet/fastapi-oauth2/issues/new/choose ) or
11
11
a [ discussion] ( https://github.com/pysnippet/fastapi-oauth2/discussions/new/choose ) if your question is not covered by
12
12
the documentation.
13
13
14
- ## User authentication
14
+ ## Authentication
15
15
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
17
17
generated the client ID and secret to configure your ` OAuth2Middleware ` with at least one client configuration.
18
18
19
19
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
28
28
Once the authentication is successful, the user will be redirected to the ` redirect_uri ` and the ` request.user ` will
29
29
contain the user information obtained from the IDP.
30
30
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
-
56
31
## Claims mapping
57
32
58
33
The ` Claims ` class includes permanent attributes like ` display_name ` , ` identity ` , ` picture ` , and ` email ` . It also allows
@@ -88,8 +63,8 @@ Claims(
88
63
89
64
::: info NOTE
90
65
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.
93
68
94
69
``` mermaid
95
70
flowchart LR
@@ -102,9 +77,32 @@ flowchart LR
102
77
103
78
:::
104
79
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
106
93
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
+ :::
108
106
109
107
<style >
110
108
.info {
0 commit comments