Return the username in a separate service

This allows us to use a service implementation which
returns a dummy user during development and the actual authenticated
user during production.  It also simplifies tests.
This commit is contained in:
Simon Goller 2024-04-26 22:41:44 +02:00
parent 789981ee92
commit 926ac006e7
3 changed files with 29 additions and 7 deletions

View file

@ -12,7 +12,15 @@ async fn main() {
let hello_dao = dao_impl::HelloDaoImpl::new(pool.clone());
let permission_dao = dao_impl::PermissionDaoImpl::new(pool);
let permission_service = service_impl::PermissionServiceImpl::new(permission_dao.into());
// Always authenticate with DEVUSER during development.
// This is used to test the permission service locally without a login service.
//
// TODO: Implement a proper authentication service when used in produciton. Maybe
// use differnet implementations on debug then on release. Or control it via a
// feature.
let user_service = service_impl::UserServiceDev;
let permission_service =
service_impl::PermissionServiceImpl::new(permission_dao.into(), user_service.into());
let hello_service =
service_impl::HelloServiceImpl::new(hello_dao.into(), permission_service.into());
rest::start_server(hello_service).await