@@ -48,6 +48,7 @@ def verify_token(token: str, app: Optional[App] = None) -> FpnvToken:
4848 FpnvToken: The verified token claims.
4949
5050 Raises:
51+ ValueError: If the token is not a string or is empty.
5152 InvalidFpnvTokenError: If the token is invalid or malformed.
5253 ExpiredFpnvTokenError: If the token has expired.
5354 """
@@ -129,7 +130,9 @@ def verify_token(self, token) -> FpnvToken:
129130 FpnvToken: The verified token claims.
130131
131132 Raises:
132- ValueError: If the token is invalid or malformed.
133+ ValueError: If the token is not a string or is empty.
134+ InvalidFpnvTokenError: If the token is invalid or malformed.
135+ ExpiredFpnvTokenError: If the token has expired.
133136 """
134137 return FpnvToken (self ._verifier .verify (token ))
135138
@@ -211,9 +214,12 @@ def _decode_and_verify(self, token, signing_key) -> Dict[str, Any]:
211214 f'Decoding FPNV token failed. Error: { exception } '
212215 ) from exception
213216
214- _Validators .check_string (
215- 'The provided FPNV token "sub" (subject) claim' ,
216- payload .get ('sub' ))
217+ sub_claim = payload .get ('sub' )
218+ if not isinstance (sub_claim , str ) or not sub_claim :
219+ raise InvalidFpnvTokenError (
220+ 'The provided FPNV token has an incorrect "sub" (subject) claim. '
221+ 'Expected a non-empty string.'
222+ )
217223
218224 return payload
219225
0 commit comments