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

Function validate_jwt

crates/common/src/utils.rs:379–390  ·  view source on GitHub ↗

Validate a JWT with the given secret

(jwt: Jwt, secret: &str)

Source from the content-addressed store, hash-verified

377
378/// Validate a JWT with the given secret
379pub fn validate_jwt(jwt: Jwt, secret: &str) -> eyre::Result<()> {
380 let mut validation = jsonwebtoken::Validation::default();
381 validation.leeway = 10;
382
383 jsonwebtoken::decode::<JwtClaims>(
384 jwt.as_str(),
385 &jsonwebtoken::DecodingKey::from_secret(secret.as_ref()),
386 &validation,
387 )
388 .map(|_| ())
389 .map_err(From::from)
390}
391
392/// Generates a random string
393pub fn random_jwt_secret() -> String {

Callers 2

check_jwt_authFunction · 0.85
test_jwt_validationFunction · 0.85

Calls

no outgoing calls

Tested by 1

test_jwt_validationFunction · 0.68