the37lab-authlib 0.1.1751371611__tar.gz → 0.1.1755164205__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of the37lab-authlib might be problematic. Click here for more details.

Files changed (15) hide show
  1. {the37lab_authlib-0.1.1751371611 → the37lab_authlib-0.1.1755164205}/PKG-INFO +1 -1
  2. {the37lab_authlib-0.1.1751371611 → the37lab_authlib-0.1.1755164205}/pyproject.toml +1 -1
  3. {the37lab_authlib-0.1.1751371611 → the37lab_authlib-0.1.1755164205}/src/the37lab_authlib/auth.py +7 -2
  4. {the37lab_authlib-0.1.1751371611 → the37lab_authlib-0.1.1755164205}/src/the37lab_authlib.egg-info/PKG-INFO +1 -1
  5. {the37lab_authlib-0.1.1751371611 → the37lab_authlib-0.1.1755164205}/README.md +0 -0
  6. {the37lab_authlib-0.1.1751371611 → the37lab_authlib-0.1.1755164205}/setup.cfg +0 -0
  7. {the37lab_authlib-0.1.1751371611 → the37lab_authlib-0.1.1755164205}/src/the37lab_authlib/__init__.py +0 -0
  8. {the37lab_authlib-0.1.1751371611 → the37lab_authlib-0.1.1755164205}/src/the37lab_authlib/db.py +0 -0
  9. {the37lab_authlib-0.1.1751371611 → the37lab_authlib-0.1.1755164205}/src/the37lab_authlib/decorators.py +0 -0
  10. {the37lab_authlib-0.1.1751371611 → the37lab_authlib-0.1.1755164205}/src/the37lab_authlib/exceptions.py +0 -0
  11. {the37lab_authlib-0.1.1751371611 → the37lab_authlib-0.1.1755164205}/src/the37lab_authlib/models.py +0 -0
  12. {the37lab_authlib-0.1.1751371611 → the37lab_authlib-0.1.1755164205}/src/the37lab_authlib.egg-info/SOURCES.txt +0 -0
  13. {the37lab_authlib-0.1.1751371611 → the37lab_authlib-0.1.1755164205}/src/the37lab_authlib.egg-info/dependency_links.txt +0 -0
  14. {the37lab_authlib-0.1.1751371611 → the37lab_authlib-0.1.1755164205}/src/the37lab_authlib.egg-info/requires.txt +0 -0
  15. {the37lab_authlib-0.1.1751371611 → the37lab_authlib-0.1.1755164205}/src/the37lab_authlib.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: the37lab_authlib
3
- Version: 0.1.1751371611
3
+ Version: 0.1.1755164205
4
4
  Summary: Python SDK for the Authlib
5
5
  Author-email: the37lab <info@the37lab.com>
6
6
  Classifier: Programming Language :: Python :: 3
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "the37lab_authlib"
7
- version = "0.1.1751371611"
7
+ version = "0.1.1755164205"
8
8
  description = "Python SDK for the Authlib"
9
9
  authors = [{name = "the37lab", email = "info@the37lab.com"}]
10
10
  dependencies = ["flask", "psycopg2-binary", "pyjwt", "python-dotenv", "requests", "authlib", "bcrypt"]
@@ -11,6 +11,7 @@ import bcrypt
11
11
  import logging
12
12
  import os
13
13
  from functools import wraps
14
+ from isodate import parse_duration
14
15
 
15
16
  logging.basicConfig(level=logging.DEBUG)
16
17
  logger = logging.getLogger(__name__)
@@ -40,6 +41,10 @@ class AuthManager:
40
41
  user_override_env = os.getenv(f'{prefix}USER_OVERRIDE')
41
42
  if user_override_env:
42
43
  self.user_override = user_override_env
44
+ else:
45
+ prefix = ''
46
+
47
+ self.expiry_time = parse_duration(os.getenv(f'{prefix}JWT_TOKEN_EXPIRY_TIME', 'PT1H'))
43
48
  if self.user_override and (api_tokens or db_dsn):
44
49
  raise ValueError('Cannot set user_override together with api_tokens or db_dsn')
45
50
  if api_tokens and db_dsn:
@@ -487,12 +492,12 @@ class AuthManager:
487
492
  def _create_token(self, user):
488
493
  payload = {
489
494
  'sub': str(user['id']),
490
- 'exp': datetime.utcnow() + timedelta(hours=1),
495
+ 'exp': datetime.utcnow() + self.expiry_time,
491
496
  'iat': datetime.utcnow()
492
497
  }
493
498
  logger.debug(f"Creating token with payload: {payload}")
494
499
  token = jwt.encode(payload, self.jwt_secret, algorithm='HS256')
495
- logger.debug(f"Created token: {token}")
500
+ logger.info(f"Created token: {token}")
496
501
  return token
497
502
 
498
503
  def _create_refresh_token(self, user):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: the37lab_authlib
3
- Version: 0.1.1751371611
3
+ Version: 0.1.1755164205
4
4
  Summary: Python SDK for the Authlib
5
5
  Author-email: the37lab <info@the37lab.com>
6
6
  Classifier: Programming Language :: Python :: 3