graphs renamed to web

This commit is contained in:
Priec
2026-08-03 12:23:50 +02:00
parent f77e23a986
commit 35d85de556
47 changed files with 19 additions and 19 deletions

21
web/src/services/mod.rs Normal file
View File

@@ -0,0 +1,21 @@
use axum::http::HeaderMap;
use tonic::{Request, metadata::MetadataValue};
#[derive(Debug)]
pub(crate) enum AuthenticationError {
Missing,
Invalid,
}
pub(crate) fn authenticated_request<T>(
headers: &HeaderMap,
message: T,
) -> Result<Request<T>, AuthenticationError> {
let token = crate::cookie_value(headers, "analytics_token")
.ok_or(AuthenticationError::Missing)?;
let value = MetadataValue::try_from(format!("Bearer {token}"))
.map_err(|_| AuthenticationError::Invalid)?;
let mut request = Request::new(message);
request.metadata_mut().insert("authorization", value);
Ok(request)
}