pyeudiw.jwt package
Submodules
pyeudiw.jwt.exceptions module
- exception pyeudiw.jwt.exceptions.LifetimeException[source]
Bases:
ValidationErrorException raised for errors related to lifetime validation.
pyeudiw.jwt.helper module
pyeudiw.jwt.jwe_helper module
pyeudiw.jwt.jws_helper module
pyeudiw.jwt.log module
pyeudiw.jwt.parse module
- class pyeudiw.jwt.parse.DecodedJwt(jwt: str, header: dict, payload: dict, signature: str)[source]
Bases:
objectSchema class for a decoded jwt. This class is not meant to be instantiated directly. Use instead the static method parse(str) -> DecodedJwt.
- header: dict
- jwt: str
- static parse(jws: str) DecodedJwt[source]
Parse a token into its components.
- Raises:
ValueError – if the token is not a jwt
- Parameters:
jws (str) – the token to parse
- payload: dict
- signature: str
- pyeudiw.jwt.parse.unsafe_parse_jws(token: str) DecodedJwt[source]
Parse a token into its components. Correctness of this function is not guaranteed when the token is in a derived format, such as sd-jwt and jwe.
- Parameters:
token (str) – the token to parse
- Raises:
JWTDecodeError – if the token is not a jwt
JWTInvalidElementPosition – if the token is not a jwt
- Returns:
the decoded jwt
- Return type:
pyeudiw.jwt.utils module
- pyeudiw.jwt.utils.base64_urldecode(v: str) bytes[source]
Urlsafe base64 decoding. This function will handle missing padding symbols.
- Returns:
the decoded data in bytes, format, convert to str use method ‘.decode(“utf-8”)’ on result
- Return type:
bytes
- pyeudiw.jwt.utils.base64_urlencode(v: bytes) str[source]
Urlsafe base64 encoding without padding symbols
- Returns:
the encooded data
- Return type:
str
- pyeudiw.jwt.utils.decode_jwt_element(jwt: str, position: int) dict[source]
Decodes the element in a determinated position.
- Parameters:
jwt (str) – a string that represents the jwt.
position (int) – the position of segment to unpad.
- Raises:
JWTInvalidElementPosition – If the JWT element position is greather then one or less of 0
JWTDecodeError – If the JWT element cannot be decoded.
- Returns:
a dict with the content of the decoded section.
- Return type:
dict
- pyeudiw.jwt.utils.decode_jwt_header(jwt: str) dict[source]
Decodes the jwt header.
- Parameters:
jwt (str) – a string that represents the jwt.
- Raises:
JWTDecodeError – If the JWT header cannot be decoded.
JWTInvalidElementPosition – If the JWT element position is missing
- Returns:
a dict with the content of the decoded header.
- Return type:
dict
- pyeudiw.jwt.utils.decode_jwt_payload(jwt: str) dict[source]
Decodes the jwt payload.
- Parameters:
jwt (str) – a string that represents the jwt.
- Raises:
JWTDecodeError – If the JWT header cannot be decoded.
JWTInvalidElementPosition – If the JWT element position is missing
- Returns:
a dict with the content of the decoded payload.
- Return type:
dict