From dfe5d4d73df55a16821d1ffad4916b98f001cb86 Mon Sep 17 00:00:00 2001 From: aumetra Date: Wed, 18 Dec 2024 00:28:08 +0100 Subject: [PATCH] more rfc compliance --- lib/komainu/src/code_grant.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/komainu/src/code_grant.rs b/lib/komainu/src/code_grant.rs index 9d681bd84..d006b3a38 100644 --- a/lib/komainu/src/code_grant.rs +++ b/lib/komainu/src/code_grant.rs @@ -5,6 +5,7 @@ use std::{ borrow::{Borrow, Cow}, collections::HashSet, future::Future, + ops::Deref, str::FromStr, }; use strum::{AsRefStr, Display}; @@ -76,14 +77,15 @@ where return Err(GrantError::AccessDenied); } - let scope = query.get("scope").or_invalid_request()?; - let redirect_uri = query.get("redirect_uri").or_invalid_request()?; + let scope = query.get("scope").map(Deref::deref).unwrap_or(""); let state = query.get("state").map(|state| &**state); let client = self.client_extractor.extract(client_id, None).await?; - if client.redirect_uri != *redirect_uri { - debug!(?client_id, "redirect uri doesn't match"); - return Err(GrantError::AccessDenied); + if let Some(redirect_uri) = query.get("redirect_uri") { + if client.redirect_uri != *redirect_uri { + debug!(?client_id, "redirect uri doesn't match"); + return Err(GrantError::AccessDenied); + } } let request_scopes = scope.split_whitespace().collect::>();