Skip to content

Commit

Permalink
more rfc compliance
Browse files Browse the repository at this point in the history
  • Loading branch information
aumetra committed Dec 17, 2024
1 parent b48719c commit dfe5d4d
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/komainu/src/code_grant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use std::{
borrow::{Borrow, Cow},
collections::HashSet,
future::Future,
ops::Deref,
str::FromStr,
};
use strum::{AsRefStr, Display};
Expand Down Expand Up @@ -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::<HashSet<_>>();
Expand Down

0 comments on commit dfe5d4d

Please sign in to comment.