Skip to content

Instantly share code, notes, and snippets.

@yottatsa
Last active August 29, 2015 14:26
Show Gist options
  • Save yottatsa/5b83aeda42e60e0afd68 to your computer and use it in GitHub Desktop.
Save yottatsa/5b83aeda42e60e0afd68 to your computer and use it in GitHub Desktop.
def validate_token(self, token):
"""Validates a Fernet token and returns the payload attributes."""
# Convert v2 unicode token to a string
if not isinstance(token, six.binary_type):
token = token.encode('ascii')
#to
def validate_token(self, token):
"""Validates a Fernet token and returns the payload attributes."""
# Convert v2 unicode token to a string
if isinstance(token, six.text_type):
token = token.encode('ascii')
if not isinstance(token, six.binary_type):
raise exception.ValidationError(_('This is not a recognized Fernet token'))
@yottatsa
Copy link
Author

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