(claims, audience=None, issuer=None, subject=None, algorithm=None, access_token=None, options=None)
| 473 | |
| 474 | |
| 475 | def _validate_claims(claims, audience=None, issuer=None, subject=None, algorithm=None, access_token=None, options=None): |
| 476 | leeway = options.get("leeway", 0) |
| 477 | |
| 478 | if isinstance(leeway, timedelta): |
| 479 | leeway = timedelta_total_seconds(leeway) |
| 480 | required_claims = [e[len("require_") :] for e in options.keys() if e.startswith("require_") and options[e]] |
| 481 | for require_claim in required_claims: |
| 482 | if require_claim not in claims: |
| 483 | raise JWTError('missing required key "%s" among claims' % require_claim) |
| 484 | else: |
| 485 | options["verify_" + require_claim] = True # override verify when required |
| 486 | |
| 487 | if not isinstance(audience, ((str,), type(None))): |
| 488 | raise JWTError("audience must be a string or None") |
| 489 | |
| 490 | if options.get("verify_iat"): |
| 491 | _validate_iat(claims) |
| 492 | |
| 493 | if options.get("verify_nbf"): |
| 494 | _validate_nbf(claims, leeway=leeway) |
| 495 | |
| 496 | if options.get("verify_exp"): |
| 497 | _validate_exp(claims, leeway=leeway) |
| 498 | |
| 499 | if options.get("verify_aud"): |
| 500 | _validate_aud(claims, audience=audience) |
| 501 | |
| 502 | if options.get("verify_iss"): |
| 503 | _validate_iss(claims, issuer=issuer) |
| 504 | |
| 505 | if options.get("verify_sub"): |
| 506 | _validate_sub(claims, subject=subject) |
| 507 | |
| 508 | if options.get("verify_jti"): |
| 509 | _validate_jti(claims) |
| 510 | |
| 511 | if options.get("verify_at_hash"): |
| 512 | _validate_at_hash(claims, access_token, algorithm) |
no test coverage detected
searching dependent graphs…