@@ -77,38 +77,38 @@ def _from_jwt(cls, headers, payload, key=None):
77
77
def payload (self ):
78
78
if self .__decoded_payload :
79
79
return self .__decoded_payload
80
- else :
81
- payload = self ._generate_payload ().copy ()
82
- payload ['iss' ] = self .issuer
83
- payload ['nbf' ] = self .nbf or int (time .time ())
84
- payload ['exp' ] = int (time .time ()) + self .ttl
85
- if self .valid_until :
86
- payload ['exp' ] = self .valid_until
87
- if self .subject :
88
- payload ['sub' ] = self .subject
89
-
90
- return payload
80
+
81
+ payload = self ._generate_payload ().copy ()
82
+ payload ['iss' ] = self .issuer
83
+ payload ['nbf' ] = self .nbf or int (time .time ())
84
+ payload ['exp' ] = int (time .time ()) + self .ttl
85
+ if self .valid_until :
86
+ payload ['exp' ] = self .valid_until
87
+ if self .subject :
88
+ payload ['sub' ] = self .subject
89
+
90
+ return payload
91
91
92
92
@property
93
93
def headers (self ):
94
94
if self .__decoded_headers :
95
95
return self .__decoded_headers
96
- else :
97
- headers = self ._generate_headers ().copy ()
98
- headers ['typ' ] = 'JWT'
99
- headers ['alg' ] = self .algorithm
100
- return headers
96
+
97
+ headers = self ._generate_headers ().copy ()
98
+ headers ['typ' ] = 'JWT'
99
+ headers ['alg' ] = self .algorithm
100
+ return headers
101
101
102
102
def to_jwt (self , algorithm = None , ttl = None ):
103
103
"""
104
- Encode this Jwt object into a Jwt string
105
- :param str algorithm: override the algorithm used to encode the jwt
104
+ Encode this JWT object into a JWT string
105
+ :param str algorithm: override the algorithm used to encode the JWT
106
106
:param int ttl: override the ttl configured in the constructor
107
- :rtype: str The Jwt string
107
+ :rtype: str The JWT string
108
108
"""
109
109
110
110
if not self .secret_key :
111
- raise ValueError ('Jwt does not have a signing key configured.' )
111
+ raise ValueError ('JWT does not have a signing key configured.' )
112
112
113
113
headers = self .headers .copy ()
114
114
if algorithm :
@@ -124,11 +124,11 @@ def to_jwt(self, algorithm=None, ttl=None):
124
124
@classmethod
125
125
def from_jwt (cls , jwt , key = '' ):
126
126
"""
127
- Decode a Jwt string into a Jwt object
128
- :param str jwt: jwt string
129
- :param Optional[str] key: key used to verify jwt signature, if not provided then validation
127
+ Decode a JWT string into a Jwt object
128
+ :param str jwt: JWT string
129
+ :param Optional[str] key: key used to verify JWT signature, if not provided then validation
130
130
is skipped.
131
- :raises JwtDecodeError if decoding jwt fails for any reason.
131
+ :raises JwtDecodeError if decoding JWT fails for any reason.
132
132
:return: A DecodedJwt object containing the jwt information.
133
133
"""
134
134
verify = True if key else False
0 commit comments