pub struct Key {
pub algorithm: Algorithm,
pub operations: HashSet<KeyOperation>,
pub key: KeyType,
pub kid: Option<KeyId>,
pub guest: Vec<String>,
pub guest_sub: Vec<String>,
pub guest_pub: Vec<String>,
/* private fields */
}Expand description
JWK, almost to spec (https://datatracker.ietf.org/doc/html/rfc7517) but not quite the same because it’s annoying to implement.
Fields§
§algorithm: AlgorithmThe algorithm used by the key.
operations: HashSet<KeyOperation>The operations that the key can perform.
key: KeyTypeDefaults to KeyType::OCT
kid: Option<KeyId>The key ID, useful for rotating keys.
guest: Vec<String>Path prefixes for both unauthenticated subscribe and publish access.
Shorthand for setting both guest_sub and guest_pub.
guest_sub: Vec<String>Path prefixes for unauthenticated subscribe access. "" means everything.
guest_pub: Vec<String>Path prefixes for unauthenticated publish access. "" means everything.
Implementations§
Source§impl<'de> Key
impl<'de> Key
pub fn deserialize<__D>(__deserializer: __D) -> Result<Key, __D::Error>where
__D: Deserializer<'de>,
Source§impl Key
impl Key
pub fn from_str(s: &str) -> Result<Self>
Sourcepub fn from_file<P: AsRef<StdPath>>(path: P) -> Result<Self>
pub fn from_file<P: AsRef<StdPath>>(path: P) -> Result<Self>
Load a key from a file, auto-detecting JSON or base64url encoding.
pub fn to_str(&self) -> Result<String>
Sourcepub fn to_file<P: AsRef<StdPath>>(&self, path: P) -> Result<()>
pub fn to_file<P: AsRef<StdPath>>(&self, path: P) -> Result<()>
Write the key to a file as JSON.
Sourcepub fn to_file_base64url<P: AsRef<StdPath>>(&self, path: P) -> Result<()>
pub fn to_file_base64url<P: AsRef<StdPath>>(&self, path: P) -> Result<()>
Write the key to a file as base64url-encoded JSON.
pub fn to_public(&self) -> Result<Self>
pub fn decode(&self, token: &str) -> Result<Claims>
pub fn encode(&self, payload: &Claims) -> Result<String>
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Key
impl<'de> Deserialize<'de> for Key
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl !Freeze for Key
impl RefUnwindSafe for Key
impl Send for Key
impl Sync for Key
impl Unpin for Key
impl UnsafeUnpin for Key
impl UnwindSafe for Key
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
Mutably borrows from an owned value. Read more