the37lab-authlib 0.1.1750952955__tar.gz → 0.1.1751357568__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.1750952955 → the37lab_authlib-0.1.1751357568}/PKG-INFO +8 -1
  2. {the37lab_authlib-0.1.1750952955 → the37lab_authlib-0.1.1751357568}/README.md +7 -0
  3. {the37lab_authlib-0.1.1750952955 → the37lab_authlib-0.1.1751357568}/pyproject.toml +1 -1
  4. {the37lab_authlib-0.1.1750952955 → the37lab_authlib-0.1.1751357568}/src/the37lab_authlib/auth.py +13 -1
  5. {the37lab_authlib-0.1.1750952955 → the37lab_authlib-0.1.1751357568}/src/the37lab_authlib.egg-info/PKG-INFO +8 -1
  6. {the37lab_authlib-0.1.1750952955 → the37lab_authlib-0.1.1751357568}/setup.cfg +0 -0
  7. {the37lab_authlib-0.1.1750952955 → the37lab_authlib-0.1.1751357568}/src/the37lab_authlib/__init__.py +0 -0
  8. {the37lab_authlib-0.1.1750952955 → the37lab_authlib-0.1.1751357568}/src/the37lab_authlib/db.py +0 -0
  9. {the37lab_authlib-0.1.1750952955 → the37lab_authlib-0.1.1751357568}/src/the37lab_authlib/decorators.py +0 -0
  10. {the37lab_authlib-0.1.1750952955 → the37lab_authlib-0.1.1751357568}/src/the37lab_authlib/exceptions.py +0 -0
  11. {the37lab_authlib-0.1.1750952955 → the37lab_authlib-0.1.1751357568}/src/the37lab_authlib/models.py +0 -0
  12. {the37lab_authlib-0.1.1750952955 → the37lab_authlib-0.1.1751357568}/src/the37lab_authlib.egg-info/SOURCES.txt +0 -0
  13. {the37lab_authlib-0.1.1750952955 → the37lab_authlib-0.1.1751357568}/src/the37lab_authlib.egg-info/dependency_links.txt +0 -0
  14. {the37lab_authlib-0.1.1750952955 → the37lab_authlib-0.1.1751357568}/src/the37lab_authlib.egg-info/requires.txt +0 -0
  15. {the37lab_authlib-0.1.1750952955 → the37lab_authlib-0.1.1751357568}/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.1750952955
3
+ Version: 0.1.1751357568
4
4
  Summary: Python SDK for the Authlib
5
5
  Author-email: the37lab <info@the37lab.com>
6
6
  Classifier: Programming Language :: Python :: 3
@@ -54,6 +54,7 @@ from authlib import AuthManager
54
54
 
55
55
  app = Flask(__name__)
56
56
 
57
+ # Option 1: Explicit configuration
57
58
  auth = AuthManager(
58
59
  app=app,
59
60
  db_dsn="postgresql://user:pass@localhost/dbname",
@@ -66,6 +67,11 @@ auth = AuthManager(
66
67
  }
67
68
  )
68
69
 
70
+ # Option 2: Use environment variables with a prefix (e.g., AMPA_)
71
+ # This will load:
72
+ # AMPA_DATABASE_URL, AMPA_JWT_SECRET, AMPA_GOOGLE_CLIENT_ID, AMPA_GOOGLE_CLIENT_SECRET
73
+ # auth = AuthManager(app=app, environment_prefix="AMPA")
74
+
69
75
  @app.route("/protected")
70
76
  @auth.require_auth(roles=["admin"])
71
77
  def protected_route():
@@ -96,6 +102,7 @@ public using the `@auth.public_endpoint` decorator or
96
102
  - `oauth_config`: Dictionary of OAuth provider configurations (see below)
97
103
  - `token_expiry`: JWT token expiry time in seconds (default: 3600)
98
104
  - `refresh_token_expiry`: Refresh token expiry time in seconds (default: 2592000)
105
+ - `environment_prefix`: If set, loads all configuration from environment variables with this prefix (e.g., `AMPA_DATABASE_URL`, `AMPA_JWT_SECRET`, `AMPA_GOOGLE_CLIENT_ID`, `AMPA_GOOGLE_CLIENT_SECRET`). Overrides other config if set.
99
106
 
100
107
  #### Example `oauth_config`:
101
108
  ```python
@@ -37,6 +37,7 @@ from authlib import AuthManager
37
37
 
38
38
  app = Flask(__name__)
39
39
 
40
+ # Option 1: Explicit configuration
40
41
  auth = AuthManager(
41
42
  app=app,
42
43
  db_dsn="postgresql://user:pass@localhost/dbname",
@@ -49,6 +50,11 @@ auth = AuthManager(
49
50
  }
50
51
  )
51
52
 
53
+ # Option 2: Use environment variables with a prefix (e.g., AMPA_)
54
+ # This will load:
55
+ # AMPA_DATABASE_URL, AMPA_JWT_SECRET, AMPA_GOOGLE_CLIENT_ID, AMPA_GOOGLE_CLIENT_SECRET
56
+ # auth = AuthManager(app=app, environment_prefix="AMPA")
57
+
52
58
  @app.route("/protected")
53
59
  @auth.require_auth(roles=["admin"])
54
60
  def protected_route():
@@ -79,6 +85,7 @@ public using the `@auth.public_endpoint` decorator or
79
85
  - `oauth_config`: Dictionary of OAuth provider configurations (see below)
80
86
  - `token_expiry`: JWT token expiry time in seconds (default: 3600)
81
87
  - `refresh_token_expiry`: Refresh token expiry time in seconds (default: 2592000)
88
+ - `environment_prefix`: If set, loads all configuration from environment variables with this prefix (e.g., `AMPA_DATABASE_URL`, `AMPA_JWT_SECRET`, `AMPA_GOOGLE_CLIENT_ID`, `AMPA_GOOGLE_CLIENT_SECRET`). Overrides other config if set.
82
89
 
83
90
  #### Example `oauth_config`:
84
91
  ```python
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "the37lab_authlib"
7
- version = "0.1.1750952955"
7
+ version = "0.1.1751357568"
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"]
@@ -16,7 +16,19 @@ logging.basicConfig(level=logging.DEBUG)
16
16
  logger = logging.getLogger(__name__)
17
17
 
18
18
  class AuthManager:
19
- def __init__(self, app=None, db_dsn=None, jwt_secret=None, oauth_config=None, id_type='integer'):
19
+ def __init__(self, app=None, db_dsn=None, jwt_secret=None, oauth_config=None, id_type='integer', environment_prefix=None):
20
+ if environment_prefix:
21
+ prefix = environment_prefix.upper() + '_'
22
+ db_dsn = os.getenv(f'{prefix}DATABASE_URL')
23
+ jwt_secret = os.getenv(f'{prefix}JWT_SECRET')
24
+ google_client_id = os.getenv(f'{prefix}GOOGLE_CLIENT_ID')
25
+ google_client_secret = os.getenv(f'{prefix}GOOGLE_CLIENT_SECRET')
26
+ oauth_config = {}
27
+ if google_client_id and google_client_secret:
28
+ oauth_config['google'] = {
29
+ 'client_id': google_client_id,
30
+ 'client_secret': google_client_secret
31
+ }
20
32
  self.db = Database(db_dsn, id_type=id_type) if db_dsn else None
21
33
  self.jwt_secret = jwt_secret
22
34
  self.oauth_config = oauth_config or {}
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: the37lab_authlib
3
- Version: 0.1.1750952955
3
+ Version: 0.1.1751357568
4
4
  Summary: Python SDK for the Authlib
5
5
  Author-email: the37lab <info@the37lab.com>
6
6
  Classifier: Programming Language :: Python :: 3
@@ -54,6 +54,7 @@ from authlib import AuthManager
54
54
 
55
55
  app = Flask(__name__)
56
56
 
57
+ # Option 1: Explicit configuration
57
58
  auth = AuthManager(
58
59
  app=app,
59
60
  db_dsn="postgresql://user:pass@localhost/dbname",
@@ -66,6 +67,11 @@ auth = AuthManager(
66
67
  }
67
68
  )
68
69
 
70
+ # Option 2: Use environment variables with a prefix (e.g., AMPA_)
71
+ # This will load:
72
+ # AMPA_DATABASE_URL, AMPA_JWT_SECRET, AMPA_GOOGLE_CLIENT_ID, AMPA_GOOGLE_CLIENT_SECRET
73
+ # auth = AuthManager(app=app, environment_prefix="AMPA")
74
+
69
75
  @app.route("/protected")
70
76
  @auth.require_auth(roles=["admin"])
71
77
  def protected_route():
@@ -96,6 +102,7 @@ public using the `@auth.public_endpoint` decorator or
96
102
  - `oauth_config`: Dictionary of OAuth provider configurations (see below)
97
103
  - `token_expiry`: JWT token expiry time in seconds (default: 3600)
98
104
  - `refresh_token_expiry`: Refresh token expiry time in seconds (default: 2592000)
105
+ - `environment_prefix`: If set, loads all configuration from environment variables with this prefix (e.g., `AMPA_DATABASE_URL`, `AMPA_JWT_SECRET`, `AMPA_GOOGLE_CLIENT_ID`, `AMPA_GOOGLE_CLIENT_SECRET`). Overrides other config if set.
99
106
 
100
107
  #### Example `oauth_config`:
101
108
  ```python