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

Fix auto login #1362

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Fix auto login #1362

wants to merge 4 commits into from

Conversation

ModEnter
Copy link
Collaborator

Fix the automatic enter of the only oauth providers, which makes it unable to logout

@ModEnter
Copy link
Collaborator Author

@dokterbob I did a new PR from the good branch this time 😉

Copy link
Collaborator

@dokterbob dokterbob left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just reviewed the functionality (in our own app, with a single oauth provider).

What I hoped this would do, was to remove the intermittent login step before the redirect, which our users have found confusing (as there's no user interaction required).

What instead happened, is that now there is a single button for the user to click; there is a choice to be made but nothing to choose. Remember those websites back in the 90's with the 'Click here to ender the website'-button?

Of course, users need to be able to log out and I see the pain there. Our own users also have this issue.

What's happening AFAIK, is that when a user logs out from chainlit, the oauth authentication is immediately initiated again. If a user was not logged out from the oauth provider, this means that they are automatically logged in again. What the user's expectation is instead, is that when they're logging out, they are presented a prompt to log in again. If there's a single OAuth provider, they should end up seeing that provider's oauth login screen again (not a page with a single button).

So IMHO, what's necessary is that logging a user out in the frontend also logs them out on the oauth backend. The proper way might be to add an optional async def logout() method to OAuthProvider which for each OAuth provider uses the available credentials to have the provider revoke their credentials.

Alternatively, if 'properly' implementing OAuth (logout) (not a trivial matter!), perhaps we could make this behaviour configurable, setting prior behaviour as the default (e.g. single_oauth_auto_redirect = True, allowing users to specifically disable it?

@dokterbob
Copy link
Collaborator

I could not help myself from digging a little deeper and it seems that OAuth2 has a prompt=consent option to the auth request. This way, a user is not logged out from their OAuth provider (we don't want users to log out from GH if they use GH to login to Chainlit!), but it will require users to confirm their login (and allow them to change to a different user).

To implement this, we could add prompt=consent on all outgoing auth requests -- which AFAIK (we need to test this) only happens when a user as logged out, requiring chainlit to send the request in the first place.

That seems like a much simpler and elegant solution!

@dokterbob
Copy link
Collaborator

@ModEnter
Copy link
Collaborator Author

Hello, this method is interesting, I'm going to dig that.

@dokterbob dokterbob added the evaluate-with-priority What's needed to address this one? label Sep 24, 2024
@dosubot dosubot bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Sep 27, 2024
@ModEnter
Copy link
Collaborator Author

@dokterbob I restored the previous behaviour and added prompt=consent to the authorization params for each one of the 9 chainlit external providers, as refered here

@dokterbob
Copy link
Collaborator

here

Great! Could you please indicate to what extent you manually tested it? It's essential for this we do extensive manual testing!

@ModEnter
Copy link
Collaborator Author

Sure, I only tested it on github oauth, but since it is defined in the OpenID connect core 1.0 spec, it should be sure that it work with the other one. If you want to test them, it would be great, I personnaly do not have the possibility to do so...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
evaluate-with-priority What's needed to address this one? size:S This PR changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants