Skip to content

Commit 63f0422

Browse files
committed
Write up the "User provisioning" section
1 parent 8e358c9 commit 63f0422

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

docs/references/tutorials.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
---
2+
outline: deep
3+
---
4+
15
# Tutorials
26

37
This documentation section contains samples and tutorials on important topics of using the library. Look at
@@ -26,6 +30,29 @@ contain the user information obtained from the IDP.
2630

2731
## User provisioning
2832

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+
2956
## Claims mapping
3057

3158
The `Claims` class includes permanent attributes like `display_name`, `identity`, `picture`, and `email`. It also allows
@@ -78,3 +105,9 @@ flowchart LR
78105
## CSRF protection
79106

80107
## PKCE support
108+
109+
<style>
110+
.info {
111+
border: 0;
112+
}
113+
</style>

0 commit comments

Comments
 (0)