-
Notifications
You must be signed in to change notification settings - Fork 251
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
client: Add SSO Login #176
Conversation
I added the sso login functions and created an Maybe we want to show a message on the webpage after the login is successful? That message would need to be customizable by the client app. |
You may mock something up with mockito, e.g. instead of launching a browser to a normal request using another
That's a good idea, the Weechat helper shows a message as well. |
I managed to make a test that still launches the browser but resolves right away without user action. It won't work in CI though in my opinion, and it's a bit annoying that it opens a page in the browser when you run tests. How could I prevent that? Should I add an optional parameter to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice, the doc tests fail so we'll need to fix this. And there's a bit of discussion to be had about the concrete API we want to offer.
matrix_sdk/src/client.rs
Outdated
/// let client = Client::new(homeserver).unwrap(); | ||
/// | ||
/// let response = client | ||
/// .login_with_sso(None, Some("My app")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This example doesn't match reality. The tests fail for this, but CI passes since the feature is disabled by default, we should probably add another CI task that tests this feature.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, sorry about that. I forgot to update the example after implementing the function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should I take care of the new CI task here or in another PR? I'm also not sure what command to use because locally when I launch cargo test --features docs
, it applies the regular test but not the docs test of the login_with_sso
method.
This is the API I've come up with for now: pub async fn login_with_sso(
&self,
server_url: Option<&str>,
server_response: Option<&str>,
use_sso_login_url: impl Fn(Uri) -> Result<()>,
device_id: Option<&str>,
initial_device_display_name: Option<&str>,
) -> Result<login::Response> With the arguments description:
|
Looks good, let's just move the methods that are inside an |
I rebased the branch on master and I applied the requested changes. It uses One thing I'm not certain about is that the error returned is mostly |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, couple of nits still. By the way, has this been tested on a real server as well?
I applied the changes. Instead of using
Yes, I've tested with a small CLI program with my Matrix account on tedomum.net. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good, I think we can merge after the last couple of nits are fixed.
Changes applied |
Thanks, merged. |
The goal is to enable full SSO Login support from the client:
get_login_types
,get_sso_login_url
andlogin_with_token
login_with_sso
function behind a feature flag that handles the whole process:These can be handled separately:
login
tologin_with_password
?login
with a generic function that accepts anylogin::LoginInfo
?Fixes #173