Skip to content

Commit 04a45f0

Browse files
committed
feat(oidc_client): add custom_scopes option to request_device_authorization
1 parent 65dbe14 commit 04a45f0

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

crates/matrix-sdk/src/authentication/common_oidc/oidc_client.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,15 +124,16 @@ impl OidcClient {
124124
pub(crate) async fn request_device_authorization(
125125
&self,
126126
device_id: Curve25519PublicKey,
127+
custom_scopes: Option<Vec<ScopeToken>>,
127128
) -> Result<CoreDeviceAuthorizationResponse, DeviceAuhorizationOidcError> {
128-
let scopes = [
129+
let scopes = custom_scopes.unwrap_or(vec![
129130
ScopeToken::Openid,
130131
ScopeToken::MatrixApi(MatrixApiScopeToken::Full),
131132
ScopeToken::try_with_matrix_device(device_id.to_base64()).expect(
132133
"We should be able to create a scope token from a \
133134
Curve25519 public key encoded as base64",
134135
),
135-
]
136+
])
136137
.into_iter()
137138
.map(|scope| Scope::new(scope.to_string()));
138139

crates/matrix-sdk/src/authentication/qrcode/login.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,8 @@ impl<'a> IntoFuture for LoginWithQrCode<'a> {
128128
// Let's tell the OIDC provider that we want to log in using the device
129129
// authorization grant described in [RFC8628](https://datatracker.ietf.org/doc/html/rfc8628).
130130
trace!("Requesting device authorization.");
131-
let auth_grant_response = oidc_client.request_device_authorization(device_id).await?;
131+
let auth_grant_response =
132+
oidc_client.request_device_authorization(device_id, None).await?;
132133

133134
// Now we need to inform the other device of the login protocols we picked and
134135
// the URL they should use to log us in.

0 commit comments

Comments
 (0)