the37lab-authlib 0.1.1750952955__py3-none-any.whl → 0.1.1751357568__py3-none-any.whl
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.
- the37lab_authlib/auth.py +13 -1
- {the37lab_authlib-0.1.1750952955.dist-info → the37lab_authlib-0.1.1751357568.dist-info}/METADATA +8 -1
- {the37lab_authlib-0.1.1750952955.dist-info → the37lab_authlib-0.1.1751357568.dist-info}/RECORD +5 -5
- {the37lab_authlib-0.1.1750952955.dist-info → the37lab_authlib-0.1.1751357568.dist-info}/WHEEL +0 -0
- {the37lab_authlib-0.1.1750952955.dist-info → the37lab_authlib-0.1.1751357568.dist-info}/top_level.txt +0 -0
the37lab_authlib/auth.py
CHANGED
|
@@ -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 {}
|
{the37lab_authlib-0.1.1750952955.dist-info → the37lab_authlib-0.1.1751357568.dist-info}/METADATA
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: the37lab_authlib
|
|
3
|
-
Version: 0.1.
|
|
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
|
{the37lab_authlib-0.1.1750952955.dist-info → the37lab_authlib-0.1.1751357568.dist-info}/RECORD
RENAMED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
the37lab_authlib/__init__.py,sha256=cFVTWL-0YIMqwOMVy1P8mOt_bQODJp-L9bfp2QQ8CTo,132
|
|
2
|
-
the37lab_authlib/auth.py,sha256=
|
|
2
|
+
the37lab_authlib/auth.py,sha256=VaLcpnuFyW5p_9bdtrrF906c0Q0vIKZx2E411EX8LZI,21834
|
|
3
3
|
the37lab_authlib/db.py,sha256=fTXxnfju0lmbFGPVbXpTMeDmJMeBgURVZTndyxyRyCc,2734
|
|
4
4
|
the37lab_authlib/decorators.py,sha256=L-gJUUwDUT2JXTptQ6XEey1LkI5RprbqzEfArWI7F8Y,1305
|
|
5
5
|
the37lab_authlib/exceptions.py,sha256=mdplK5sKNtagPAzSGq5NGsrQ4r-k03DKJBKx6myWwZc,317
|
|
6
6
|
the37lab_authlib/models.py,sha256=-PlvQlHGIsSdrH0H9Cdh_vTPlltGV8G1Z1mmGQvAg9Y,3422
|
|
7
|
-
the37lab_authlib-0.1.
|
|
8
|
-
the37lab_authlib-0.1.
|
|
9
|
-
the37lab_authlib-0.1.
|
|
10
|
-
the37lab_authlib-0.1.
|
|
7
|
+
the37lab_authlib-0.1.1751357568.dist-info/METADATA,sha256=17HRY5bNhRD5UE3xN8uhQf5SwKw6LePUtwER5Vb1sfY,6851
|
|
8
|
+
the37lab_authlib-0.1.1751357568.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
9
|
+
the37lab_authlib-0.1.1751357568.dist-info/top_level.txt,sha256=6Jmxw4UeLrhfJXgRKbXWY4OhxRSaMs0dKKhNCGWWSwc,17
|
|
10
|
+
the37lab_authlib-0.1.1751357568.dist-info/RECORD,,
|
{the37lab_authlib-0.1.1750952955.dist-info → the37lab_authlib-0.1.1751357568.dist-info}/WHEEL
RENAMED
|
File without changes
|
|
File without changes
|