betagouv / pad.numerique.gouv.fr

Pad numérique de l'état
https://pad.numerique.gouv.fr/
GNU Affero General Public License v3.0
6 stars 1 forks source link

True SSO #57

Closed lebaudantoine closed 2 months ago

lebaudantoine commented 2 months ago

Description

Thx a lot @manuhabitela, amazing peer-coding session. It's deployed in staging if you wanna give it a try.

The code is pretty straightforward. I make an initial call to Agent Connect, with prompt parameter set to None. For more context on the prompt parameters, please refer to its description in the spec:

(prompt = None) : The Authorization Server MUST NOT display any authentication or consent user interface pages. An error is returned if an End-User is not already authenticated or the Client does not have pre-configured consent for the requested Claims or does not fulfill other conditions for processing the request. The error code will typically be login_required, interaction_required, or another code defined in Section 3.1.2.6. This can be used as a method to check for existing authentication and/or consent.

Why adding this logic?

Implementing this mechanism enhances the user experience by providing true Single Sign-On (SSO) for users navigating to the pad. If they are already logged in with Agent Connect in another Suite product, they won't need to log in again. I will document this approach in the "La Suite integration" section to share it with other teams (Résana, France Transfert, etc.).

Areas for Improvement

The current implementation of Agent Connect only returns the login_required error. If the error code is modified in the future, my PR might break. Although this change won't happen any soon, the code could still be improved.

Additionally, URLs are hard-coded and constructed manually. While this aligns with the existing (suboptimal) codebase standards, it presents an opportunity for improvement.