MCPcopy Create free account
hub / github.com/Commit-Boost/commit-boost-client / decode_jwt

Function decode_jwt

crates/common/src/utils.rs:362–376  ·  view source on GitHub ↗

Decode a JWT and return the module id. IMPORTANT: This function does not validate the JWT, it only obtains the module id from the claims.

(jwt: Jwt)

Source from the content-addressed store, hash-verified

360/// Decode a JWT and return the module id. IMPORTANT: This function does not
361/// validate the JWT, it only obtains the module id from the claims.
362pub fn decode_jwt(jwt: Jwt) -> eyre::Result<ModuleId> {
363 let mut validation = jsonwebtoken::Validation::default();
364 validation.insecure_disable_signature_validation();
365
366 let module = jsonwebtoken::decode::<JwtClaims>(
367 jwt.as_str(),
368 &jsonwebtoken::DecodingKey::from_secret(&[]),
369 &validation,
370 )?
371 .claims
372 .module
373 .into();
374
375 Ok(module)
376}
377
378/// Validate a JWT with the given secret
379pub fn validate_jwt(jwt: Jwt, secret: &str) -> eyre::Result<()> {

Callers 2

check_jwt_authFunction · 0.85
test_jwt_validationFunction · 0.85

Calls

no outgoing calls

Tested by 1

test_jwt_validationFunction · 0.68