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

0.0.7 #13

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
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: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
source_suffix = '.rst'
master_doc = 'index'
project = 'Authentic'
year = '2018'
year = '2021'
author = 'Subhash Bhushan C'
copyright = '{0}, {1}'.format(year, author)
version = release = '0.0.6'
version = release = '0.0.7'

pygments_style = 'trac'
templates_path = ['.']
Expand Down
2 changes: 1 addition & 1 deletion requirements/test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ pytest-cov==2.5.1
pytest-travis-fold==1.3.0
pytest-env==0.6.2
pluggy==0.6.0
cryptography==2.4.1
cryptography==3.2
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def read(*names, **kwargs):

setup(
name='authentic',
version='0.0.6a',
version='0.0.7a',
license='BSD 3-Clause License',
description='Comprehensive Authentication Package',
long_description='%s\n%s' % (
Expand Down
22 changes: 17 additions & 5 deletions src/authentic/backends/jwt/usecases.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,19 +119,31 @@ def process_request(self, request_object):
Status.UNAUTHORIZED, {'credentials': f'Invalid JWT Token. {e}'})

# Find the identity in the decoded jwt
identity = jwt_data.get(active_config.JWT_IDENTITY_CLAIM, None)

try:
if jwt_data.get('id'):
account = self.repo.filter(username=jwt_data.get('id')).first
jwt_data[active_config.JWT_IDENTITY_CLAIM] = {'account_id': account.id}
identity = jwt_data.get(active_config.JWT_IDENTITY_CLAIM, None)
account = self.repo.get(identity.get('account_id'))
except ObjectNotFoundError:
except (ObjectNotFoundError, AttributeError):
return ResponseFailure(
Status.UNAUTHORIZED,
Status.NOT_FOUND,
{'username_or_email': 'Account does not exist'})

# Make sure that the session exits
session = repo.SessionSchema.filter(
session_key=f'token-{account.id}-{jwt_data["jti"]}',
)
if not session or session.first.expire_date < datetime.utcnow():
).first
if not session and jwt_data.get('id'):
session = repo.SessionSchema.create(
session_key=f'token-{account.id}'
f'-{jwt_data["jti"]}',
session_data={},
expire_date=datetime.utcnow() +
active_config.JWT_ACCESS_TOKEN_EXPIRES
)
if not session or session.expire_date < datetime.utcnow():
return ResponseFailure(
Status.UNAUTHORIZED, {'token': 'Invalid Token'})

Expand Down