Wrap Context with Autentication enum

Context should contain information which is required to get
the information if the service call is authenticated.  Context
could be the username for example.  But services call other
services internally and for this, authentication must not be
checked.  In this case, they can now pass Authentication::Full
which always successfully authenticates.
This commit is contained in:
Simon Goller 2024-05-09 14:58:19 +02:00
parent bf94ec33de
commit b0000c0117
18 changed files with 252 additions and 217 deletions

View file

@ -70,7 +70,7 @@ pub async fn get_all_bookings<RestState: RestStateDef>(rest_state: State<RestSta
(async {
let bookings: Arc<[BookingTO]> = rest_state
.booking_service()
.get_all(())
.get_all(().into())
.await?
.iter()
.map(BookingTO::from)
@ -90,7 +90,7 @@ pub async fn get_booking<RestState: RestStateDef>(
) -> Response {
error_handler(
(async {
let booking = rest_state.booking_service().get(booking_id, ()).await?;
let booking = rest_state.booking_service().get(booking_id, ().into()).await?;
Ok(Response::builder()
.status(200)
.body(Body::new(
@ -110,7 +110,7 @@ pub async fn create_booking<RestState: RestStateDef>(
(async {
let booking = rest_state
.booking_service()
.create(&Booking::from(&booking), ())
.create(&Booking::from(&booking), ().into())
.await?;
Ok(Response::builder()
.status(200)
@ -129,7 +129,7 @@ pub async fn delete_booking<RestState: RestStateDef>(
) -> Response {
error_handler(
(async {
rest_state.booking_service().delete(booking_id, ()).await?;
rest_state.booking_service().delete(booking_id, ().into()).await?;
Ok(Response::builder().status(200).body(Body::empty()).unwrap())
})
.await,