async fn request_filter(state: RequestState, authentication: Authentication) -> Flow<()> {
let state = state.into_headers_state().await;
let header_handler = state.handler();
let auth = authentication.authentication().unwrap_or_default();
let properties = auth.properties.as_object().cloned().unwrap_or_default();
let client_id = header_handler
.header("custom_client_id_header")
.unwrap_or_default();
let client_name = header_handler
.header("custom_client_name_header")
.unwrap_or_default();
let auth = AuthenticationData::new(
auth.principal,
Some(client_id),
Some(client_name),
properties
);
authentication.set_authentication(Some(&auth));
Flow::Continue(())
}
#[entrypoint]
async fn configure(launcher: Launcher) -> Result<()> {
let filter = on_request(|rs, auth| request_filter(rs, auth));
launcher.launch(filter).await?;
Ok(())
}