Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support SSO (Single Sign-On) #64

Merged
merged 6 commits into from
Jul 25, 2024
Merged

Support SSO (Single Sign-On) #64

merged 6 commits into from
Jul 25, 2024

Conversation

lebaudantoine
Copy link
Collaborator

@lebaudantoine lebaudantoine commented Jul 24, 2024

Purpose

Offer SSO to our users.

Proposal

It closes #26. Take a look at the ticket 👀
Cleaned the POC discussed in #32, and added some tests on the backend.

Feel free to drop my last commit and build the frontend as you want. I encountered a "blinking" issue and suggest that we intercept all routes with an authentication middleware on the frontend. This middleware could display a loading spinner until we can confirm the user's login status.

Edit: your commit would probably fix the blinking issue.

Edit 2: It did not

@lebaudantoine lebaudantoine changed the title Support SSo Support SSO Jul 24, 2024
@lebaudantoine lebaudantoine changed the title Support SSO Support SSO (Single Sign-On) Jul 24, 2024
@lebaudantoine lebaudantoine self-assigned this Jul 24, 2024
@lebaudantoine lebaudantoine force-pushed the sso branch 5 times, most recently from e3897c5 to 8d603a9 Compare July 25, 2024 13:47
Woopsi. I forgot to update the package description while bootstrapping
the project. Fixed!
mozilla-django-oidc now supports a 'returnTo' parameter for redirecting
to a specificURL upon successful login. if not provided,
it defaults to the settings-defined URL.

This allows initiating the login flow from any views,
enhancing UX by returning users to their previous page.

The 'returnTo' naming can be discussed.
Silent login attempts to re-authenticate the user without interaction,
provided they have an active session, improving UX by reducing manual auth.

It's an essential feature to really feel the SSO in La Suite.

A new query parameter, 'silent', allows the client to initiate a silent login.
In this flow, an extra parameter, 'prompt=none', is passed to the OIDC provider.

The requested flow is persisted in session data to adapt the authentication
callback behavior.

In a silent login flow, an authentication failure should not be considered as a
real failure. Instead, users should be redirected back to the originating view.
A silent login fails when user has no active session.

Why return the 'success_url'? The 'success_url' will redirect the user agent to
the 'returnTo' parameter provided when requesting authentication.
It's necessary to enable a silent login on any URL.

Minimal test coverage has been added for these two custom views to ensure
correct behavior.
Enhanced the authentication URL generation to support 'silent'
and 'returnTo' query parameters.

This allows initiating a silent login and specifying a custom
return URL after auth.
@manuhabitela
Copy link
Collaborator

Thanks Antoine for this! Should be better now visually. Can you try again @lebaudantoine?

@manuhabitela manuhabitela marked this pull request as ready for review July 25, 2024 16:10
lebaudantoine and others added 2 commits July 25, 2024 22:32
This commit is totally work in progress.
@manuhabitela the floor is yours.

If the user is logged-out, try silently log-in her every hour,
to avoid any manual login on her side.

The one hour value has been discussed with @manuhabitela, but there
is no real logic behind it. Could definitely be shorter or longer.

It needs at least to be longer than the average silent login flow
to avoid locking the user-agent in an infinite redirection loop.
the issue was we return the fetchUser promise to react query too early
(before the browser reloaded the page). now we make sure react query
doesn't get the info
@lebaudantoine lebaudantoine merged commit fdff509 into main Jul 25, 2024
6 of 7 checks passed
@lebaudantoine lebaudantoine deleted the sso branch July 25, 2024 20:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support SSO
2 participants