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

Function insecure_decode

src/decoding.rs:296–306  ·  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

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

Callers

nothing calls this directly

Calls 1

deserializeMethod · 0.45

Tested by

no test coverage detected