@@ -2,7 +2,7 @@ Client applications
2
2
===================
3
3
4
4
If you are writing a client application, you will probably want to test the nominal authentication case,
5
- i.e. the case when the users successfully logs in and give their consent to your application.
5
+ i.e. the case when the users successfully log in and give their consent to your application.
6
6
Depending on your implementation, you might also need to test how your application behaves in case
7
7
of error during the authentication process.
8
8
@@ -16,7 +16,7 @@ Setting up your test
16
16
Users & groups
17
17
~~~~~~~~~~~~~~
18
18
19
- You can use the available :class: `~canaille.core.models.User ` and :class: `~canaille.core.models.Group ` models to set up their
19
+ You can use the available :class: `~canaille.core.models.User ` and :class: `~canaille.core.models.Group ` models to set up the
20
20
IAM server for your tests. Optionally you can put them in pytest fixtures so they are reusable:
21
21
22
22
@@ -65,7 +65,7 @@ If you don't care about the data your users and group, you can use the available
65
65
OIDC Client registration
66
66
~~~~~~~~~~~~~~~~~~~~~~~~
67
67
68
- Before your application can authenticate against the IAM server, it must register and give provide details
68
+ Before your application can authenticate against the IAM server, it must register and provide details
69
69
such as the allowed redirection URIs. To achieve this you can use the :class: `~canaille.oidc.basemodels.Client `
70
70
model. Let us suppose your application have a ``/authorize `` endpoint for the authorization code - token exchange:
71
71
@@ -88,6 +88,12 @@ model. Let us suppose your application have a ``/authorize`` endpoint for the au
88
88
yield inst
89
89
iam_server.backend.delete(inst)
90
90
91
+ .. note ::
92
+
93
+ Canaille has a :attr: `~canaille.oidc.basemodels.Client.trusted ` parameter.
94
+ When it is :data: `True ` for a client, end-users won't be showed a consent page
95
+ when the client redirect them to the IAM authorization page.
96
+
91
97
Note that the IAM implements the `OAuth2/OIDC dynamic client registration protocol <https://datatracker.ietf.org/doc/html/rfc7591 >`_,
92
98
thus you might not need a client fixture if your application dynamically register one. No *initial token * is needed to use dynamic
93
99
client registration. Here is an example of dynamic registration you can implement in your application:
@@ -109,18 +115,12 @@ client registration. Here is an example of dynamic registration you can implemen
109
115
client_id = response.json[" client_id" ]
110
116
client_secret = response.json[" client_secret" ]
111
117
112
- .. note ::
113
-
114
- Canaille has a :attr: `~canaille.oidc.basemodels.Client.trusted ` parameter.
115
- When it is :data: `True ` for a client, end-users won't be showed a consent page
116
- when the client redirect them to the IAM authorization page.
117
-
118
118
Nominal authentication workflow
119
119
-------------------------------
120
120
121
- Let us suppose that your application have a ``/protected `` that redirects users
121
+ Let us suppose that your application have a ``/protected `` endpoint tthat redirects users
122
122
to the IAM server if unauthenticated.
123
- We suppose you have a test client fixture like werkzeug :class: `~werkzeug.test.Client `
123
+ We suppose that you have a ` test_client ` fixture like werkzeug :class: `~werkzeug.test.Client `
124
124
that allows to test your application endpoints without real HTTP requests.
125
125
pytest-iam provides its own test client, available with :meth: `~pytest_iam.Server.test_client `.
126
126
Let us see how to implement an authorization_code authentication test case:
0 commit comments