pub struct JweDecryptPlugin {
header: String,
forward_header: String,
strict: bool,
inline_key: Option<Vec<u8>>,
use_consumers: bool,
resources: Arc<PluginResources>,
}Expand description
Decrypts a JWE dir+A256GCM token and forwards the plaintext downstream.
On success the decrypted plaintext replaces the value of forward_header
in the outbound request; the request otherwise continues unchanged through
the success port. On any failure (missing token when strict,
malformed compact serialization, unsupported algorithm, unknown kid, or a
failed AEAD check) the request is rejected with a 401 JSON response and a
JWE_INVALID error routed through the error port.
Fields§
§header: StringLowercased header the encrypted token is read from.
forward_header: StringLowercased header the decrypted plaintext is written to.
strict: boolWhen true, a missing token is rejected; when false the request passes through untouched.
inline_key: Option<Vec<u8>>Inline symmetric key (32 raw bytes) when configured; takes precedence over the consumer store.
use_consumers: boolWhen true, resolve the key from the consumer store using the token kid.
resources: Arc<PluginResources>Implementations§
Source§impl JweDecryptPlugin
impl JweDecryptPlugin
Sourcepub fn from_config(
config: &HashMap<String, Value>,
resources: &Arc<PluginResources>,
) -> Result<Self, String>
pub fn from_config( config: &HashMap<String, Value>, resources: &Arc<PluginResources>, ) -> Result<Self, String>
Builds the plugin from node config.
Accepted keys:
header(string, default"Authorization"): header carrying the JWE token; matched case-insensitively (an optionalBearerprefix is stripped).forward_header(string, default"Authorization"): header the decrypted plaintext is written to before proxying.strict(bool, defaulttrue): when true a missing token is rejected; when false the request passes through unchanged.key(string, optional): inline symmetric key, base64-encoded, which must decode to exactly 32 bytes (AES-256). Used for every request.use_consumers(bool, defaultfalse): resolve the key per request from the gatewayconsumers:section — the token’skidselects the consumer’sjwe-decryptcredential ({key: <kid>, secret: <32-byte key>, is_base64_encoded: <bool>}).- At least one of
key/use_consumersmust be provided. alg(string, default"dir") /enc(string, default"A256GCM"): only these values are supported; any other value is a config error (fail-fast at load), since full JWE is not implemented.
type: jwe-decrypt
config:
header: Authorization
forward_header: Authorization
strict: true
use_consumers: trueSourcefn reject(
ctx: Context,
message: &str,
) -> Result<PluginOutput, PluginExecutionError>
fn reject( ctx: Context, message: &str, ) -> Result<PluginOutput, PluginExecutionError>
Builds the 401 rejection (code JWE_INVALID) carrying the context so the
graph engine routes through the error port.
Trait Implementations§
Source§impl Plugin for JweDecryptPlugin
impl Plugin for JweDecryptPlugin
Source§fn plugin_type(&self) -> &str
fn plugin_type(&self) -> &str
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,
Auto Trait Implementations§
impl Freeze for JweDecryptPlugin
impl !RefUnwindSafe for JweDecryptPlugin
impl Send for JweDecryptPlugin
impl Sync for JweDecryptPlugin
impl Unpin for JweDecryptPlugin
impl UnsafeUnpin for JweDecryptPlugin
impl !UnwindSafe for JweDecryptPlugin
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
§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>
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>
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