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

Box the repository everywhere

This commit is contained in:
Quentin Gliech
2023-01-20 17:49:16 +01:00
parent f4c64c2171
commit a9facab131
49 changed files with 296 additions and 296 deletions

View File

@@ -72,10 +72,10 @@ pub enum Credentials {
}
impl Credentials {
pub async fn fetch<'r, R>(&self, repo: &'r mut R) -> Result<Option<Client>, R::Error>
where
R: Repository,
{
pub async fn fetch<E>(
&self,
repo: &mut (impl Repository<Error = E> + ?Sized),
) -> Result<Option<Client>, E> {
let client_id = match self {
Credentials::None { client_id }
| Credentials::ClientSecretBasic { client_id, .. }

View File

@@ -43,10 +43,10 @@ impl SessionInfo {
}
/// Load the [`BrowserSession`] from database
pub async fn load_session<R: Repository>(
pub async fn load_session<E>(
&self,
repo: &mut R,
) -> Result<Option<BrowserSession>, R::Error> {
repo: &mut (impl Repository<Error = E> + ?Sized),
) -> Result<Option<BrowserSession>, E> {
let session_id = if let Some(id) = self.current {
id
} else {

View File

@@ -51,11 +51,10 @@ enum AccessToken {
}
impl AccessToken {
async fn fetch<R: Repository>(
async fn fetch<E>(
&self,
repo: &mut R,
) -> Result<(mas_data_model::AccessToken, Session), AuthorizationVerificationError<R::Error>>
{
repo: &mut (impl Repository<Error = E> + ?Sized),
) -> Result<(mas_data_model::AccessToken, Session), AuthorizationVerificationError<E>> {
let token = match self {
AccessToken::Form(t) | AccessToken::Header(t) => t,
AccessToken::None => return Err(AuthorizationVerificationError::MissingToken),
@@ -85,11 +84,11 @@ pub struct UserAuthorization<F = ()> {
impl<F: Send> UserAuthorization<F> {
// TODO: take scopes to validate as parameter
pub async fn protected_form<R: Repository, C: Clock>(
pub async fn protected_form<E>(
self,
repo: &mut R,
clock: &C,
) -> Result<(Session, F), AuthorizationVerificationError<R::Error>> {
repo: &mut (impl Repository<Error = E> + ?Sized),
clock: &impl Clock,
) -> Result<(Session, F), AuthorizationVerificationError<E>> {
let form = match self.form {
Some(f) => f,
None => return Err(AuthorizationVerificationError::MissingForm),
@@ -105,11 +104,11 @@ impl<F: Send> UserAuthorization<F> {
}
// TODO: take scopes to validate as parameter
pub async fn protected<R: Repository, C: Clock>(
pub async fn protected<E>(
self,
repo: &mut R,
clock: &C,
) -> Result<Session, AuthorizationVerificationError<R::Error>> {
repo: &mut (impl Repository<Error = E> + ?Sized),
clock: &impl Clock,
) -> Result<Session, AuthorizationVerificationError<E>> {
let (token, session) = self.access_token.fetch(repo).await?;
if !token.is_valid(clock.now()) || !session.is_valid() {