Skip to main content

hyperlane_plugin_auth/
lib.rs

1//! hyperlane-plugin-auth
2//!
3//! Pure-Rust high-performance authentication and RBAC plugin for Hyperlane
4//! with HS256 JWT (`kid` rotation, `exp`/`nbf`/`iss`/`aud`), API key and
5//! HTTP Basic authenticators, constant-time verification, and extensible
6//! async [`Authenticator`] traits.
7
8mod r#const;
9mod r#enum;
10mod r#fn;
11mod r#impl;
12mod r#static;
13mod r#struct;
14mod r#trait;
15mod r#type;
16
17#[cfg(test)]
18#[path = "../tests/mod.rs"]
19mod tests;
20
21pub use {r#const::*, r#enum::*, r#fn::*, r#struct::*, r#trait::*, r#type::*};
22
23pub(crate) use r#static::*;
24
25#[cfg(all(target_arch = "aarch64", target_endian = "little"))]
26use std::arch::{
27    aarch64::{
28        uint8x16_t, uint32x4_t, vaddq_u32, vdupq_n_u8, veorq_u8, vld1q_u8, vld1q_u32,
29        vreinterpretq_u8_u32, vreinterpretq_u32_u8, vrev32q_u8, vsha256h2q_u32, vsha256hq_u32,
30        vsha256su0q_u32, vsha256su1q_u32, vst1q_u8, vst1q_u32,
31    },
32    is_aarch64_feature_detected,
33};
34
35use std::{
36    borrow::Cow,
37    collections::{HashMap, VecDeque},
38    error::Error,
39    fmt::{self, Display, Formatter},
40    future::Future,
41    io::{self, Write},
42    pin::Pin,
43    str::from_utf8,
44    sync::{Arc, OnceLock},
45    time::{Duration, SystemTime, UNIX_EPOCH},
46};
47
48use {
49    hyperlane::{
50        AUTHORIZATION, Context, HashMapXxHash3_64, HashSetXxHash3_64, HttpStatus, Request,
51        Response, ResponseError, ServerHook, Status, Stream, WWW_AUTHENTICATE, X_API_KEY,
52        hash_map_xx_hash3_64, hash_set_xx_hash3_64,
53    },
54    lombok_macros::*,
55    serde::{
56        Deserialize, Deserializer, Serialize, Serializer,
57        de::{self, MapAccess, Visitor},
58        ser::SerializeMap,
59    },
60    serde_json::{Value, from_slice, to_vec, to_writer},
61};