pub struct DataMaskPlugin {
rules: Vec<MaskRule>,
max_body_size: usize,
}Expand description
Masks request query parameters, headers, and JSON body fields according
to a list of rules. Masking is best-effort and never fails at execution
time: bodies that are absent, non-JSON, or larger than max_body_size
simply skip the body rules. The plugin only touches context.request;
it never writes context.message or context.errors.
Fields§
§rules: Vec<MaskRule>§max_body_size: usizeImplementations§
Source§impl DataMaskPlugin
impl DataMaskPlugin
Sourcepub fn from_config(config: &HashMap<String, Value>) -> Result<Self, String>
pub fn from_config(config: &HashMap<String, Value>) -> Result<Self, String>
Builds the plugin from node config.
Accepted keys:
request(array of rule objects, default[]): each rule hastype(string, required):query,header, orbody.name(string, required): the query parameter / header name, or a dotted path into the JSON body (user.cards.0.number; numeric segments index arrays, a leading$.is tolerated).action(string, required):remove,replace, orregex.value(string): replacement value; required forreplaceandregex(forregexit may use$1capture references).regex(string): pattern; required foraction: regex, compiled here at config load.body_format(string): required fortype: body; onlyjsonis supported (deviation: APISIX also acceptsurlencoded).
max_body_size(integer > 0, default1048576): bodies larger than this skip body rules.
type: data-mask
config:
request:
- { type: header, name: authorization, action: replace, value: "***" }
- { type: query, name: token, action: remove }
- type: body
body_format: json
name: user.card_number
action: regex
regex: "^(\\d{4})\\d+(\\d{4})$"
value: "$1********$2"Trait Implementations§
Source§impl Plugin for DataMaskPlugin
impl Plugin for DataMaskPlugin
Source§fn plugin_type(&self) -> &str
fn plugin_type(&self) -> &str
Unique identifier for the plugin type (e.g., “proxy-rewrite”, “upstream”).
Source§fn execute<'life0, 'life1, 'async_trait>(
&'life0 self,
ctx: Context,
_named_inputs: &'life1 HashMap<String, Value>,
) -> Pin<Box<dyn Future<Output = Result<PluginOutput, PluginExecutionError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn execute<'life0, 'life1, 'async_trait>(
&'life0 self,
ctx: Context,
_named_inputs: &'life1 HashMap<String, Value>,
) -> Pin<Box<dyn Future<Output = Result<PluginOutput, PluginExecutionError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Executes the plugin logic against the request/response context. Read more
Auto Trait Implementations§
impl Freeze for DataMaskPlugin
impl RefUnwindSafe for DataMaskPlugin
impl Send for DataMaskPlugin
impl Sync for DataMaskPlugin
impl Unpin for DataMaskPlugin
impl UnsafeUnpin for DataMaskPlugin
impl UnwindSafe for DataMaskPlugin
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more