Reimplemented access and refresh tokens.

This commit is contained in:
2026-10-18 13:21:48 +02:00
parent 4343959c74
commit 26999d690f
28 changed files with 1510 additions and 480 deletions
+3 -3
View File
@@ -3,7 +3,7 @@ use sqlx::PgPool;
use super::{AuthScheme, Authorizer, Principal};
use crate::{
crypto::hash_secret,
domain::Secret,
repository::{self, RepositoryError},
};
@@ -32,8 +32,8 @@ where
) -> Result<Principal<Self>, Self::Error> {
let pool = PgPool::from_ref(state);
let token_hash = hash_secret(&credentials.0);
let token = repository::tokens::get_by_access_token_hash(&pool, &token_hash)
let token_hash = Secret::from(credentials.0).hash();
let token = repository::tokens::get_access_token_by_hash(&pool, &token_hash)
.await
.map_err(BearerError::Repository)?
.ok_or(BearerError::InvalidCredentials)?;