Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Next Minor #184

Merged
merged 5 commits into from
Jun 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions masonite/auth/Sign.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from cryptography.fernet import Fernet
from masonite.exceptions import InvalidSecretKey


class Sign:
Expand All @@ -12,6 +13,9 @@ def __init__(self, key=None):
from config import application
self.key = application.KEY

if not self.key:
raise InvalidSecretKey("The encryption key passed in is: None. Be sure there is a secret key present in your .env file or your config/application.py file.")

self.encryption = None

def sign(self, value):
Expand Down
4 changes: 3 additions & 1 deletion masonite/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,6 @@ class ResponseError(Exception): pass

class InvalidAutoloadPath(Exception): pass

class AutoloadContainerOverwrite(Exception): pass
class AutoloadContainerOverwrite(Exception): pass

class InvalidSecretKey(Exception): pass
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
'masonite.contracts',
'masonite.helpers',
],
version='2.0.4',
version='2.0.5',
install_requires=[
'validator.py==1.2.5',
'cryptography==2.2.2',
Expand Down
7 changes: 3 additions & 4 deletions tests/test_signing.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from masonite.auth.Sign import Sign
from cryptography.fernet import Fernet


from masonite.exceptions import InvalidSecretKey
import pytest


class TestSigning:
Expand All @@ -12,8 +12,7 @@ def setup_method(self):
def test_unsigning_returns_decrypted_value_with_parameter(self):
s = Sign(self.secret_key)
assert s.unsign(s.sign('value')) == 'value'



def test_unsigning_returns_decrypted_value_without_parameter(self):
s = Sign(self.secret_key)
assert s.unsign(s.sign('value')) == 'value'
Expand Down