fedimint_server_core/net.rs
1use fedimint_core::module::{ApiEndpointContext, ApiError, ApiResult};
2
3/// A token proving the the API call was authenticated
4///
5/// Api handlers are encouraged to take it as an argument to avoid sensitive
6/// guardian-only logic being accidentally unauthenticated.
7pub struct GuardianAuthToken {
8 _marker: (), // private field just to make creating it outside impossible
9}
10
11pub fn check_auth(context: &mut ApiEndpointContext) -> ApiResult<GuardianAuthToken> {
12 if context.has_auth() {
13 Ok(GuardianAuthToken { _marker: () })
14 } else {
15 Err(ApiError::unauthorized())
16 }
17}