Struct reth_rpc_layer::JwtSecret
pub struct JwtSecret(/* private fields */);
Expand description
Value-object holding a reference to a hex-encoded 256-bit secret key.
A JWT secret key is used to secure JWT-based authentication. The secret key is a shared secret between the server and the client and is used to calculate a digital signature for the JWT, which is included in the JWT along with its payload.
See also: Secret key - Engine API specs
Implementations§
§impl JwtSecret
impl JwtSecret
pub fn from_hex<S>(hex: S) -> Result<JwtSecret, JwtError>
pub fn from_hex<S>(hex: S) -> Result<JwtSecret, JwtError>
Creates an instance of JwtSecret
.
Returns an error if one of the following applies:
hex
is not a valid hexadecimal stringhex
argument length is less thanJWT_SECRET_LEN
This strips the leading 0x
, if any.
pub fn try_create_random(fpath: &Path) -> Result<JwtSecret, JwtError>
Available on crate feature std
only.
pub fn try_create_random(fpath: &Path) -> Result<JwtSecret, JwtError>
std
only.pub fn validate(&self, jwt: &str) -> Result<(), JwtError>
Available on crate feature serde
only.
pub fn validate(&self, jwt: &str) -> Result<(), JwtError>
serde
only.Validates a JWT token along the following rules:
- The JWT signature is valid.
- The JWT is signed with the
HMAC + SHA256 (HS256)
algorithm. - The JWT
iat
(issued-at) claim is a timestamp within +-60 seconds from the current time. - The JWT
exp
(expiration time) claim is validated by default if defined.
See also: JWT Claims - Engine API specs
Trait Implementations§
impl Copy for JwtSecret
impl Eq for JwtSecret
impl StructuralPartialEq for JwtSecret
Auto Trait Implementations§
impl Freeze for JwtSecret
impl RefUnwindSafe for JwtSecret
impl Send for JwtSecret
impl Sync for JwtSecret
impl Unpin for JwtSecret
impl UnwindSafe for JwtSecret
Blanket Implementations§
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§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>
§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where
S: Into<Dispatch>,
§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
impl<T> MaybeSend for Twhere
T: Send,
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 32 bytes