pyeudiw.jwt package

Submodules

pyeudiw.jwt.exceptions module

exception pyeudiw.jwt.exceptions.JWEDecryptionError[source]

Bases: Exception

exception pyeudiw.jwt.exceptions.JWEEncryptionError[source]

Bases: Exception

exception pyeudiw.jwt.exceptions.JWSSigningError[source]

Bases: Exception

exception pyeudiw.jwt.exceptions.JWSVerificationError[source]

Bases: Exception

exception pyeudiw.jwt.exceptions.JWTDecodeError[source]

Bases: Exception

exception pyeudiw.jwt.exceptions.JWTInvalidElementPosition[source]

Bases: Exception

exception pyeudiw.jwt.exceptions.LifetimeException[source]

Bases: ValidationError

Exception 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: object

Schema 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:
Returns:

the decoded jwt

Return type:

DecodedJwt

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:
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:
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:
Returns:

a dict with the content of the decoded payload.

Return type:

dict

pyeudiw.jwt.utils.is_jwe_format(jwt: str)[source]

Check if a string is in JWE format.

Parameters:

jwt (str) – a string that represents the jwt.

Returns:

True if the string is a JWE, False otherwise.

Return type:

bool

pyeudiw.jwt.utils.is_jwt_format(jwt: str) bool[source]

Check if a string is in JWT format.

Parameters:

jwt (str) – a string that represents the jwt.

Returns:

True if the string is a JWT, False otherwise.

Return type:

bool

pyeudiw.jwt.verification module

Module contents