Skip to content
This repository has been archived by the owner on Sep 10, 2024. It is now read-only.

Commit

Permalink
Use headers API
Browse files Browse the repository at this point in the history
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
  • Loading branch information
zecakeh authored and sandhose committed May 30, 2024
1 parent 683516b commit fa0dec7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions crates/oidc-client/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -452,8 +452,8 @@ pub enum UserInfoError {
DecodeResponseContentType(#[from] ToStrError),

/// The content-type is not valid.
#[error("invalid response content-type: {0}")]
InvalidResponseContentTypeValue(#[from] mime::FromStrError),
#[error("invalid response content-type")]
InvalidResponseContentTypeValue,

/// The content-type is not the one that was expected.
#[error("unexpected response content-type {got:?}, expected {expected:?}")]
Expand Down
10 changes: 5 additions & 5 deletions crates/oidc-client/src/requests/userinfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
use std::collections::HashMap;

use bytes::Bytes;
use headers::{Authorization, HeaderMapExt, HeaderValue};
use http::header::{ACCEPT, CONTENT_TYPE};
use headers::{Authorization, ContentType, HeaderMapExt, HeaderValue};
use http::header::ACCEPT;
use mas_http::CatchHttpCodesLayer;
use mas_jose::claims;
use mime::Mime;
Expand Down Expand Up @@ -101,10 +101,10 @@ pub async fn fetch_userinfo(

let content_type: Mime = userinfo_response
.headers()
.get(CONTENT_TYPE)
.typed_try_get::<ContentType>()
.map_err(|_| UserInfoError::InvalidResponseContentTypeValue)?
.ok_or(UserInfoError::MissingResponseContentType)?
.to_str()?
.parse()?;
.into();

if content_type.essence_str() != expected_content_type {
return Err(UserInfoError::UnexpectedResponseContentType {
Expand Down

0 comments on commit fa0dec7

Please sign in to comment.