athena_rs 3.22.1

Hyper performant polyglot Database driver
Documentation
//! Gateway/admin read-right authorization helpers for schema routes.
//!
//! This module owns authorization checks for schema read access used by schema
//! catalog and debug endpoints.

use actix_web::{HttpRequest, HttpResponse};

use crate::AppState;
use crate::api::gateway::auth::{read_right_for_resource, require_admin_or_gateway};

/// Enforces schema-route read authorization for gateway/admin callers.
pub(in super::super) async fn require_schema_read_authorization(
    req: &HttpRequest,
    app_state: &AppState,
    client_name: Option<&str>,
) -> Result<(), HttpResponse> {
    require_admin_or_gateway(
        req,
        app_state,
        client_name,
        vec![read_right_for_resource(None)],
    )
    .await
    .map(|_| ())
}