Skip to content

Commit 506060f

Browse files
pixlwavepoljar
authored andcommitted
sdk: Add support for generic OAuth login hints.
See element-hq/matrix-authentication-service#4512
1 parent 55d475d commit 506060f

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

crates/matrix-sdk/src/authentication/oauth/auth_code_builder.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,34 @@ impl OAuthAuthCodeUrlBuilder {
7373
self
7474
}
7575

76+
/// Set a generic login hint to help an identity provider pre-fill the login
77+
/// form.
78+
///
79+
/// Note: This is not the same as the [`Self::user_id_hint()`] method, which
80+
/// is specifically designed to a) take a `UserId` and no other type of
81+
/// hint and b) be used directly by MAS and not the identity provider.
82+
///
83+
/// The most likely use case for this method is to pre-fill the login page
84+
/// using a provisioning link provided by an external party such as
85+
/// `https://app.example.com/?server_name=example.org&login_hint=alice`
86+
/// In this instance it is up to the external party to make ensure that the
87+
/// hint is known to work with their identity provider. For more information
88+
/// see `login_hint` in <https://openid.net/specs/openid-connect-core-1_0.html#AuthRequest>
89+
///
90+
/// The following methods are mutually exclusive: [`Self::login_hint()`] and
91+
/// [`Self::user_id_hint()`].
92+
pub fn login_hint(mut self, login_hint: String) -> Self {
93+
self.login_hint = Some(login_hint);
94+
self
95+
}
96+
7697
/// Set the hint to the Authorization Server about the Matrix user ID the
7798
/// End-User might use to log in, as defined in [MSC4198].
7899
///
79100
/// [MSC4198]: https://github.com/matrix-org/matrix-spec-proposals/pull/4198
101+
///
102+
/// The following methods are mutually exclusive: [`Self::login_hint()`] and
103+
/// [`Self::user_id_hint()`].
80104
pub fn user_id_hint(mut self, user_id: &UserId) -> Self {
81105
self.login_hint = Some(format!("mxid:{user_id}"));
82106
self

0 commit comments

Comments
 (0)