From 45ceb49d3cf2676c126e5b20092a180cd9dd10bc Mon Sep 17 00:00:00 2001 From: Hsiaoming Yang Date: Wed, 6 Apr 2022 18:04:21 +0900 Subject: [PATCH] Raise InvalidClaimError for None value --- authlib/jose/rfc7519/claims.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/authlib/jose/rfc7519/claims.py b/authlib/jose/rfc7519/claims.py index e0730960..037d56f0 100644 --- a/authlib/jose/rfc7519/claims.py +++ b/authlib/jose/rfc7519/claims.py @@ -53,8 +53,11 @@ def __getattr__(self, key): def _validate_essential_claims(self): for k in self.options: - if self.options[k].get('essential') and not self.get(k): - raise MissingClaimError(k) + if self.options[k].get('essential'): + if k not in self: + raise MissingClaimError(k) + elif not self.get(k): + raise InvalidClaimError(k) def _validate_claim_value(self, claim_name): option = self.options.get(claim_name)