Codebase list python-itsdangerous / 63ae847
Merge remote-tracking branch 'remotes/origin/master' into master-dfsg Simon Fondrie-Teitler 9 years ago
5 changed file(s) with 60 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
00 It's Dangerous Changelog
11 ------------------------
2
3 Version 0.24
4 ~~~~~~~~~~~~
5
6 - Added a `BadHeader` exception that is used for bad headers
7 that replaces the old `BadPayload` exception that was reused
8 in those cases.
9
10 Version 0.23
11 ~~~~~~~~~~~~
12
13 - Fixed a packaging mistake that caused the tests and license
14 files to not be included.
215
316 Version 0.22
417 ~~~~~~~~~~~~
0 include MANIFEST.in Makefile CHANGES LICENSE tox.ini tests.py
1 recursive-include docs *
2 recursive-exclude docs/_build *
295295 .. autoexception:: SignatureExpired
296296 :members:
297297
298 .. autoexception:: BadHeader
299 :members:
300
298301 .. autoexception:: BadPayload
299302 :members:
300303
123123 that. The original exception that caused that will be stored on the
124124 exception as :attr:`original_error`.
125125
126 This can also happen with a :class:`JSONWebSignatureSerializer` that
127 is subclassed and uses a different serializer for the payload than
128 the expected one.
129
126130 .. versionadded:: 0.15
127131 """
128132
163167 #:
164168 #: .. versionadded:: 0.14
165169 self.date_signed = date_signed
170
171
172 class BadHeader(BadSignature):
173 """Raised if a signed header is invalid in some form. This only
174 happens for serializers that have a header that goes with the
175 signature.
176
177 .. versionadded:: 0.24
178 """
179
180 def __init__(self, message, payload=None, header=None,
181 original_error=None):
182 BadSignature.__init__(self, message, payload)
183
184 #: If the header is actually available but just malformed it
185 #: might be stored here.
186 self.header = header
187
188 #: If available, the error that indicates why the payload
189 #: was not valid. This might be `None`.
190 self.original_error = original_error
166191
167192
168193 class SignatureExpired(BadTimeSignature):
510535 return serializer.loads(payload)
511536 except Exception as e:
512537 raise BadPayload('Could not load the payload because an '
513 'exception ocurred on unserializing the data',
538 'exception occurred on unserializing the data',
514539 original_error=e)
515540
516541 def dump_payload(self, obj):
656681 base64d_header, base64d_payload = payload.split(b'.', 1)
657682 try:
658683 json_header = base64_decode(base64d_header)
684 except Exception as e:
685 raise BadHeader('Could not base64 decode the header because of '
686 'an exception', original_error=e)
687 try:
659688 json_payload = base64_decode(base64d_payload)
660689 except Exception as e:
661690 raise BadPayload('Could not base64 decode the payload because of '
662691 'an exception', original_error=e)
663 header = Serializer.load_payload(self, json_header,
664 serializer=json)
692 try:
693 header = Serializer.load_payload(self, json_header,
694 serializer=json)
695 except BadData as e:
696 raise BadHeader('Could not unserialize header because it was '
697 'malformed', original_error=e)
665698 if not isinstance(header, dict):
666 raise BadPayload('Header payload is not a JSON object')
699 raise BadHeader('Header payload is not a JSON object',
700 header=header)
667701 payload = Serializer.load_payload(self, json_payload)
668702 if return_header:
669703 return payload, header
711745 self.make_signer(salt, self.algorithm).unsign(want_bytes(s)),
712746 return_header=True)
713747 if header.get('alg') != self.algorithm_name:
714 raise BadSignature('Algorithm mismatch')
748 raise BadHeader('Algorithm mismatch', header=header,
749 payload=payload)
715750 if return_header:
716751 return payload, header
717752 return payload
77 name='itsdangerous',
88 author='Armin Ronacher',
99 author_email='armin.ronacher@active-4.com',
10 version='0.22',
10 version='0.23',
1111 url='http://github.com/mitsuhiko/itsdangerous',
1212 py_modules=['itsdangerous'],
1313 description='Various helpers to pass trusted data to '