MCPcopy Create free account
hub / github.com/Keats/jsonwebtoken / insecure_decode

Function insecure_decode

src/decoding.rs:301–311  ·  view source on GitHub ↗

Decode a JWT with NO VALIDATION DANGER: This performs zero validation on the JWT

(token: impl AsRef<[u8]>)

Source from the content-addressed store, hash-verified

299///
300/// DANGER: This performs zero validation on the JWT
301pub fn insecure_decode<T: DeserializeOwned>(token: impl AsRef<[u8]>) -> Result<TokenData<T>> {
302 let token = token.as_ref();
303
304 let (_, message) = expect_two!(token.rsplitn(2, |b| *b == b'.'));
305 let (payload, header) = expect_two!(message.rsplitn(2, |b| *b == b'.'));
306
307 let header = Header::from_encoded(header)?;
308 let claims = DecodedJwtPartClaims::from_jwt_part_claims(payload)?.deserialize()?;
309
310 Ok(TokenData { header, claims })
311}
312
313/// Decode a JWT without any signature verification/validations and return its [Header](struct.Header.html).
314///

Callers

nothing calls this directly

Calls 1

deserializeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…