Skip to content

Sending a garbage value to check_bewit should raise HawkFail #54

Description

@kumar303

If you do something like this:

from mohawk.bewit import check_bewit
check_bewit(
    'https://site.org/protected-image.png?bewit=just-a-random-string', 
    credential_lookup=...
)

... you'll get something like:

    Traceback (most recent call last):
      File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/doctest.py", line 1315, in __run
        compileflags, 1) in test.globs
      File "<doctest usage[14]>", line 1, in <module>
        check_bewit('{url}?bewit={bewit}'.format(url=url, bewit='INVALID'), credential_lookup=lookup_credentials)
      File "/Users/kumar/dev/mohawk/mohawk/bewit.py", line 124, in check_bewit
        bewit = parse_bewit(raw_bewit)
      File "/Users/kumar/dev/mohawk/mohawk/bewit.py", line 77, in parse_bewit
        decoded_bewit = b64decode(bewit).decode('ascii')
      File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/base64.py", line 78, in b64decode
        raise TypeError(msg)
    TypeError: Incorrect padding

This is understandable but it all exceptions raised in check_bewit should derive from HawkFail so they can be caught more easily.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions