@@ -2,7 +2,7 @@ Client applications
22===================
33
44If 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.
66Depending on your implementation, you might also need to test how your application behaves in case
77of error during the authentication process.
88
@@ -16,7 +16,7 @@ Setting up your test
1616Users & groups
1717~~~~~~~~~~~~~~
1818
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
2020IAM server for your tests. Optionally you can put them in pytest fixtures so they are reusable:
2121
2222
@@ -65,7 +65,7 @@ If you don't care about the data your users and group, you can use the available
6565 OIDC Client registration
6666~~~~~~~~~~~~~~~~~~~~~~~~
6767
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
6969such as the allowed redirection URIs. To achieve this you can use the :class: `~canaille.oidc.basemodels.Client `
7070model. Let us suppose your application have a ``/authorize `` endpoint for the authorization code - token exchange:
7171
@@ -88,6 +88,12 @@ model. Let us suppose your application have a ``/authorize`` endpoint for the au
8888 yield inst
8989 iam_server.backend.delete(inst)
9090
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+
9197Note that the IAM implements the `OAuth2/OIDC dynamic client registration protocol <https://datatracker.ietf.org/doc/html/rfc7591 >`_,
9298thus you might not need a client fixture if your application dynamically register one. No *initial token * is needed to use dynamic
9399client 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
109115 client_id = response.json[" client_id" ]
110116 client_secret = response.json[" client_secret" ]
111117
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-
118118 Nominal authentication workflow
119119-------------------------------
120120
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
122122to 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 `
124124that allows to test your application endpoints without real HTTP requests.
125125pytest-iam provides its own test client, available with :meth: `~pytest_iam.Server.test_client `.
126126Let us see how to implement an authorization_code authentication test case:
0 commit comments