Skip to content

Commit

Permalink
Revert "removed check for client ids"
Browse files Browse the repository at this point in the history
This reverts commit 17f67b6.
  • Loading branch information
caojen committed Apr 19, 2024
1 parent 17f67b6 commit e67d8ab
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
13 changes: 12 additions & 1 deletion src/async_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,20 @@ impl AsyncClient {
pub async fn validate_id_token<S>(&self, token: S) -> MyResult<GooglePayload>
where S: AsRef<str>
{
let token = token.as_ref();
// fast check:
// if there is no given client id, simple return without communicating with Google server.

let client_ids = self.client_ids.read().await;

if client_ids.is_empty() {
return Err(Error::IDTokenClientIDNotFoundError(IDTokenClientIDNotFoundError {
get: token.as_ref().to_string(),
expected: Default::default(),
}))
}

let token = token.as_ref();

let parser: JwtParser<GooglePayload> = JwtParser::parse(token)?;

id_token::validate_info(&*client_ids, &parser)?;
Expand Down
2 changes: 1 addition & 1 deletion src/validate/id_token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub fn validate_info<T, V>(client_ids: T, parser: &JwtParser<GooglePayload>) ->
T: AsRef<[V]>,
V: AsRef<str>,
{
if !client_ids.as_ref().is_empty() && !client_ids.as_ref().iter().any(|c| c.as_ref() == parser.payload.aud.as_str()) {
if !client_ids.as_ref().iter().any(|c| c.as_ref() == parser.payload.aud.as_str()) {
// bail!("id_token: audience provided does not match aud claim in the jwt");
Err(IDTokenClientIDNotFoundError::new(&parser.payload.aud, client_ids))?
}
Expand Down

0 comments on commit e67d8ab

Please sign in to comment.