cat_gateway/service/common/auth/
none.rs

1//! None authorization scheme.
2//!
3//! Means the API Endpoint does not need to use any Auth.
4
5/// Endpoint can be used without any authorization.
6pub(crate) struct NoAuthorization;
7
8impl<'a> poem_openapi::ApiExtractor<'a> for NoAuthorization {
9    type ParamRawType = ();
10    type ParamType = ();
11
12    const TYPES: &'static [poem_openapi::ApiExtractorType] =
13        &[poem_openapi::ApiExtractorType::SecurityScheme];
14
15    fn register(registry: &mut poem_openapi::registry::Registry) {
16        registry.create_security_scheme(
17            "NoAuthorization",
18            poem_openapi::registry::MetaSecurityScheme {
19                ty: "http",
20                description: Some("Endpoint can be used without any authorization."),
21                name: None,
22                key_in: None,
23                scheme: Some("none"),
24                bearer_format: None,
25                flows: None,
26                openid_connect_url: None,
27            },
28        );
29    }
30
31    fn security_schemes() -> Vec<&'static str> {
32        vec!["NoAuthorization"]
33    }
34
35    async fn from_request(
36        _req: &'a poem::Request,
37        _body: &mut poem::RequestBody,
38        _param_opts: poem_openapi::ExtractParamOptions<Self::ParamType>,
39    ) -> poem::Result<Self> {
40        Ok(Self)
41    }
42}