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
storage: wrap the postgres repository in a struct
This commit is contained in:
@@ -31,10 +31,9 @@ use mas_http::HttpServiceExt;
|
||||
use mas_iana::oauth::OAuthClientAuthenticationMethod;
|
||||
use mas_jose::{jwk::PublicJsonWebKeySet, jwt::Jwt};
|
||||
use mas_keystore::Encrypter;
|
||||
use mas_storage::{oauth2::OAuth2ClientRepository, DatabaseError, Repository};
|
||||
use mas_storage::{oauth2::OAuth2ClientRepository, Repository};
|
||||
use serde::{de::DeserializeOwned, Deserialize};
|
||||
use serde_json::Value;
|
||||
use sqlx::PgConnection;
|
||||
use thiserror::Error;
|
||||
use tower::{Service, ServiceExt};
|
||||
|
||||
@@ -73,7 +72,10 @@ pub enum Credentials {
|
||||
}
|
||||
|
||||
impl Credentials {
|
||||
pub async fn fetch(&self, conn: &mut PgConnection) -> Result<Option<Client>, DatabaseError> {
|
||||
pub async fn fetch<'r, R>(&self, repo: &'r mut R) -> Result<Option<Client>, R::Error>
|
||||
where
|
||||
R: Repository,
|
||||
{
|
||||
let client_id = match self {
|
||||
Credentials::None { client_id }
|
||||
| Credentials::ClientSecretBasic { client_id, .. }
|
||||
@@ -81,7 +83,7 @@ impl Credentials {
|
||||
| Credentials::ClientAssertionJwtBearer { client_id, .. } => client_id,
|
||||
};
|
||||
|
||||
conn.oauth2_client().find_by_client_id(client_id).await
|
||||
repo.oauth2_client().find_by_client_id(client_id).await
|
||||
}
|
||||
|
||||
#[tracing::instrument(skip_all, err)]
|
||||
|
||||
Reference in New Issue
Block a user