You've already forked authentication-service
mirror of
https://github.com/matrix-org/matrix-authentication-service.git
synced 2025-11-20 12:02:22 +03:00
committed by
Quentin Gliech
parent
683516bb66
commit
fa0dec737b
@@ -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:?}")]
|
||||
|
||||
@@ -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;
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user