Skip to content

Commit

Permalink
mypy: Rewrite sign_is_valid in zthumbor helpers.py for None secret_key.
Browse files Browse the repository at this point in the history
  • Loading branch information
neiljp authored and timabbott committed Mar 25, 2018
1 parent 8b697b4 commit 3b28d6a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
3 changes: 0 additions & 3 deletions mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,6 @@ strict_optional = False
[mypy-zilencer.management.commands.add_new_realm] #22: error: List item 0 has incompatible type "Optional[Stream]"; expected "Stream"
strict_optional = False

[mypy-zthumbor.loaders.helpers] #83: error: Argument 2 to "get_sign_hash" has incompatible type "Optional[str]"; expected "str"
strict_optional = False

# Re-architecting required?

[mypy-zerver.lib.queue] # Delayed setup of SimpleQueueClient.channel (Optional)
Expand Down
7 changes: 4 additions & 3 deletions zthumbor/loaders/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ def sign_is_valid(url, context):
force_text(size),
force_text(source_type),
])
if sign == get_sign_hash(raw, get_secret('thumbor_key')):
return True
return False
secret_key = get_secret('thumbor_key')
if secret_key is None or sign != get_sign_hash(raw, secret_key):
return False
return True

0 comments on commit 3b28d6a

Please sign in to comment.