From 1dcba67a1f607faabcdfa6f7e94d280c66dd6470 Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Mon, 4 Jul 2022 22:57:04 +0200 Subject: [PATCH] fix: oauth logins used incorrect scope --- backend/src/oauth2.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/src/oauth2.rs b/backend/src/oauth2.rs index 7d9ae0ee4b..01e93fb797 100644 --- a/backend/src/oauth2.rs +++ b/backend/src/oauth2.rs @@ -111,7 +111,6 @@ pub async fn build_oauth_clients(base_url: &str) -> anyhow::Result { .filter(|x| oauths.contains_key(&x.0)) .map(|(k, v)| { let scopes = v.scopes.clone(); - let named_client = build_basic_client( k.clone(), v, @@ -725,15 +724,16 @@ fn oauth_redirect( .ok_or_else(|| error::Error::BadRequest("client not found".to_string()))?; let state = State::new_random(); let mut client = client_w_scopes.client.clone(); - let url = client.authorize_url(&state); let scopes_iter = if let Some(scopes) = scopes { scopes } else { client_w_scopes.scopes.clone() }; + for scope in scopes_iter.iter() { client.add_scope(scope); } + let url = client.authorize_url(&state); set_cookie(&state, cookies); Ok(Redirect::to(url.as_str())) }