Use OIDC username

This commit is contained in:
Simon Goller 2024-06-05 18:00:05 +02:00
parent 9888ac4062
commit 3c670d50d3
10 changed files with 154 additions and 43 deletions

View file

@ -25,3 +25,19 @@ impl service::user_service::UserService for UserServiceDev {
Ok("DEVUSER".into())
}
}
pub struct UserServiceImpl;
#[async_trait]
impl service::user_service::UserService for UserServiceImpl {
type Context = Option<Arc<str>>;
async fn current_user(
&self,
context: Self::Context,
) -> Result<Arc<str>, service::ServiceError> {
context
.ok_or_else(|| service::ServiceError::Unauthorized)
.map(|user| user.clone())
}
}