1
0
mirror of https://github.com/matrix-org/matrix-authentication-service.git synced 2025-08-09 04:22:45 +03:00

storage: unify the compat login errors

This commit is contained in:
Quentin Gliech
2022-12-07 17:26:28 +01:00
parent 1ddc05ff01
commit f7f65e314b
14 changed files with 314 additions and 359 deletions

View File

@@ -224,7 +224,7 @@ pub enum ClientAuthorizationError {
MissingCredentials,
InvalidRequest,
InvalidAssertion,
InternalError(Box<dyn std::error::Error>),
Internal(Box<dyn std::error::Error>),
}
impl IntoResponse for ClientAuthorizationError {
@@ -289,7 +289,7 @@ where
return Err(ClientAuthorizationError::BadForm(err))
}
// Other errors (body read twice, byte stream broke) return an internal error
Err(e) => return Err(ClientAuthorizationError::InternalError(Box::new(e))),
Err(e) => return Err(ClientAuthorizationError::Internal(Box::new(e))),
};
// And now, figure out the actual auth method

View File

@@ -104,7 +104,7 @@ pub enum UserAuthorizationError {
InvalidHeader,
TokenInFormAndHeader,
BadForm(FailedToDeserializeForm),
InternalError(Box<dyn Error>),
Internal(Box<dyn Error>),
}
#[derive(Debug, Error)]
@@ -119,7 +119,7 @@ pub enum AuthorizationVerificationError {
MissingForm,
#[error(transparent)]
InternalError(Box<dyn Error>),
Internal(Box<dyn Error>),
}
impl From<AccessTokenLookupError> for AuthorizationVerificationError {
@@ -127,7 +127,7 @@ impl From<AccessTokenLookupError> for AuthorizationVerificationError {
if e.not_found() {
Self::InvalidToken
} else {
Self::InternalError(Box::new(e))
Self::Internal(Box::new(e))
}
}
}
@@ -232,9 +232,7 @@ impl IntoResponse for UserAuthorizationError {
});
(StatusCode::BAD_REQUEST, headers).into_response()
}
Self::InternalError(e) => {
(StatusCode::INTERNAL_SERVER_ERROR, e.to_string()).into_response()
}
Self::Internal(e) => (StatusCode::INTERNAL_SERVER_ERROR, e.to_string()).into_response(),
}
}
}
@@ -262,9 +260,7 @@ impl IntoResponse for AuthorizationVerificationError {
});
(StatusCode::BAD_REQUEST, headers).into_response()
}
Self::InternalError(e) => {
(StatusCode::INTERNAL_SERVER_ERROR, e.to_string()).into_response()
}
Self::Internal(e) => (StatusCode::INTERNAL_SERVER_ERROR, e.to_string()).into_response(),
}
}
}
@@ -309,7 +305,7 @@ where
return Err(UserAuthorizationError::BadForm(err))
}
// Other errors (body read twice, byte stream broke) return an internal error
Err(e) => return Err(UserAuthorizationError::InternalError(Box::new(e))),
Err(e) => return Err(UserAuthorizationError::Internal(Box::new(e))),
};
let access_token = match (token_from_header, token_from_form) {