the37lab-authlib 0.1.1750836881__tar.gz → 0.1.1750837371__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.
- {the37lab_authlib-0.1.1750836881 → the37lab_authlib-0.1.1750837371}/PKG-INFO +9 -2
- {the37lab_authlib-0.1.1750836881 → the37lab_authlib-0.1.1750837371}/README.md +8 -1
- {the37lab_authlib-0.1.1750836881 → the37lab_authlib-0.1.1750837371}/pyproject.toml +1 -1
- {the37lab_authlib-0.1.1750836881 → the37lab_authlib-0.1.1750837371}/src/the37lab_authlib/auth.py +23 -10
- {the37lab_authlib-0.1.1750836881 → the37lab_authlib-0.1.1750837371}/src/the37lab_authlib.egg-info/PKG-INFO +9 -2
- {the37lab_authlib-0.1.1750836881 → the37lab_authlib-0.1.1750837371}/setup.cfg +0 -0
- {the37lab_authlib-0.1.1750836881 → the37lab_authlib-0.1.1750837371}/src/the37lab_authlib/__init__.py +0 -0
- {the37lab_authlib-0.1.1750836881 → the37lab_authlib-0.1.1750837371}/src/the37lab_authlib/db.py +0 -0
- {the37lab_authlib-0.1.1750836881 → the37lab_authlib-0.1.1750837371}/src/the37lab_authlib/decorators.py +0 -0
- {the37lab_authlib-0.1.1750836881 → the37lab_authlib-0.1.1750837371}/src/the37lab_authlib/exceptions.py +0 -0
- {the37lab_authlib-0.1.1750836881 → the37lab_authlib-0.1.1750837371}/src/the37lab_authlib/models.py +0 -0
- {the37lab_authlib-0.1.1750836881 → the37lab_authlib-0.1.1750837371}/src/the37lab_authlib.egg-info/SOURCES.txt +0 -0
- {the37lab_authlib-0.1.1750836881 → the37lab_authlib-0.1.1750837371}/src/the37lab_authlib.egg-info/dependency_links.txt +0 -0
- {the37lab_authlib-0.1.1750836881 → the37lab_authlib-0.1.1750837371}/src/the37lab_authlib.egg-info/requires.txt +0 -0
- {the37lab_authlib-0.1.1750836881 → the37lab_authlib-0.1.1750837371}/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.
|
|
3
|
+
Version: 0.1.1750837371
|
|
4
4
|
Summary: Python SDK for the Authlib
|
|
5
5
|
Author-email: the37lab <info@the37lab.com>
|
|
6
6
|
Classifier: Programming Language :: Python :: 3
|
|
@@ -70,13 +70,20 @@ auth = AuthManager(
|
|
|
70
70
|
@auth.require_auth(roles=["admin"])
|
|
71
71
|
def protected_route():
|
|
72
72
|
return "Protected content"
|
|
73
|
+
|
|
74
|
+
@app.route("/public")
|
|
75
|
+
@auth.public_endpoint
|
|
76
|
+
def custom_public_route():
|
|
77
|
+
return "Public content"
|
|
73
78
|
```
|
|
74
79
|
|
|
75
80
|
`AuthManager`'s blueprint now registers a global error handler for
|
|
76
81
|
`AuthError` and authenticates requests for all of its routes by default.
|
|
77
82
|
Authenticated users are made available as `flask.g.requesting_user`.
|
|
78
83
|
Only the login, OAuth, token refresh, registration and role listing
|
|
79
|
-
endpoints are exempt from this check.
|
|
84
|
+
endpoints are exempt from this check. Additional routes can be marked as
|
|
85
|
+
public using the `@auth.public_endpoint` decorator or
|
|
86
|
+
`auth.add_public_endpoint("auth.some_endpoint")`.
|
|
80
87
|
|
|
81
88
|
## Configuration
|
|
82
89
|
|
|
@@ -53,13 +53,20 @@ auth = AuthManager(
|
|
|
53
53
|
@auth.require_auth(roles=["admin"])
|
|
54
54
|
def protected_route():
|
|
55
55
|
return "Protected content"
|
|
56
|
+
|
|
57
|
+
@app.route("/public")
|
|
58
|
+
@auth.public_endpoint
|
|
59
|
+
def custom_public_route():
|
|
60
|
+
return "Public content"
|
|
56
61
|
```
|
|
57
62
|
|
|
58
63
|
`AuthManager`'s blueprint now registers a global error handler for
|
|
59
64
|
`AuthError` and authenticates requests for all of its routes by default.
|
|
60
65
|
Authenticated users are made available as `flask.g.requesting_user`.
|
|
61
66
|
Only the login, OAuth, token refresh, registration and role listing
|
|
62
|
-
endpoints are exempt from this check.
|
|
67
|
+
endpoints are exempt from this check. Additional routes can be marked as
|
|
68
|
+
public using the `@auth.public_endpoint` decorator or
|
|
69
|
+
`auth.add_public_endpoint("auth.some_endpoint")`.
|
|
63
70
|
|
|
64
71
|
## Configuration
|
|
65
72
|
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "the37lab_authlib"
|
|
7
|
-
version = "0.1.
|
|
7
|
+
version = "0.1.1750837371"
|
|
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"]
|
{the37lab_authlib-0.1.1750836881 → the37lab_authlib-0.1.1750837371}/src/the37lab_authlib/auth.py
RENAMED
|
@@ -22,6 +22,15 @@ class AuthManager:
|
|
|
22
22
|
self.jwt_secret = jwt_secret
|
|
23
23
|
logger.debug(f"Initializing AuthManager with JWT secret: {jwt_secret[:5]}..." if jwt_secret else "No JWT secret provided")
|
|
24
24
|
self.oauth_config = oauth_config or {}
|
|
25
|
+
self.public_endpoints = {
|
|
26
|
+
'auth.login',
|
|
27
|
+
'auth.oauth_login',
|
|
28
|
+
'auth.oauth_callback',
|
|
29
|
+
'auth.refresh_token',
|
|
30
|
+
'auth.register',
|
|
31
|
+
'auth.get_roles'
|
|
32
|
+
}
|
|
33
|
+
self.bp = None
|
|
25
34
|
|
|
26
35
|
if app:
|
|
27
36
|
self.init_app(app)
|
|
@@ -113,6 +122,17 @@ class AuthManager:
|
|
|
113
122
|
|
|
114
123
|
return f(*args, **kwargs)
|
|
115
124
|
return decorated
|
|
125
|
+
|
|
126
|
+
def add_public_endpoint(self, endpoint):
|
|
127
|
+
"""Mark an endpoint as public so it bypasses authentication."""
|
|
128
|
+
self.public_endpoints.add(endpoint)
|
|
129
|
+
|
|
130
|
+
def public_endpoint(self, f):
|
|
131
|
+
"""Decorator to mark a view function as public."""
|
|
132
|
+
if self.bp:
|
|
133
|
+
endpoint = f"{self.bp.name}.{f.__name__}"
|
|
134
|
+
self.add_public_endpoint(endpoint)
|
|
135
|
+
return f
|
|
116
136
|
|
|
117
137
|
def init_app(self, app):
|
|
118
138
|
app.auth_manager = self
|
|
@@ -120,15 +140,8 @@ class AuthManager:
|
|
|
120
140
|
|
|
121
141
|
def create_blueprint(self):
|
|
122
142
|
bp = Blueprint('auth', __name__, url_prefix='/api/v1/users')
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
'auth.login',
|
|
126
|
-
'auth.oauth_login',
|
|
127
|
-
'auth.oauth_callback',
|
|
128
|
-
'auth.refresh_token',
|
|
129
|
-
'auth.register',
|
|
130
|
-
'auth.get_roles'
|
|
131
|
-
}
|
|
143
|
+
self.bp = bp
|
|
144
|
+
bp.public_endpoint = self.public_endpoint
|
|
132
145
|
|
|
133
146
|
@bp.errorhandler(AuthError)
|
|
134
147
|
def handle_auth_error(err):
|
|
@@ -138,7 +151,7 @@ class AuthManager:
|
|
|
138
151
|
|
|
139
152
|
@bp.before_request
|
|
140
153
|
def load_user():
|
|
141
|
-
if request.endpoint not in public_endpoints:
|
|
154
|
+
if request.endpoint not in self.public_endpoints:
|
|
142
155
|
g.requesting_user = self._authenticate_request()
|
|
143
156
|
|
|
144
157
|
@bp.route('/login', methods=['POST'])
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: the37lab_authlib
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.1750837371
|
|
4
4
|
Summary: Python SDK for the Authlib
|
|
5
5
|
Author-email: the37lab <info@the37lab.com>
|
|
6
6
|
Classifier: Programming Language :: Python :: 3
|
|
@@ -70,13 +70,20 @@ auth = AuthManager(
|
|
|
70
70
|
@auth.require_auth(roles=["admin"])
|
|
71
71
|
def protected_route():
|
|
72
72
|
return "Protected content"
|
|
73
|
+
|
|
74
|
+
@app.route("/public")
|
|
75
|
+
@auth.public_endpoint
|
|
76
|
+
def custom_public_route():
|
|
77
|
+
return "Public content"
|
|
73
78
|
```
|
|
74
79
|
|
|
75
80
|
`AuthManager`'s blueprint now registers a global error handler for
|
|
76
81
|
`AuthError` and authenticates requests for all of its routes by default.
|
|
77
82
|
Authenticated users are made available as `flask.g.requesting_user`.
|
|
78
83
|
Only the login, OAuth, token refresh, registration and role listing
|
|
79
|
-
endpoints are exempt from this check.
|
|
84
|
+
endpoints are exempt from this check. Additional routes can be marked as
|
|
85
|
+
public using the `@auth.public_endpoint` decorator or
|
|
86
|
+
`auth.add_public_endpoint("auth.some_endpoint")`.
|
|
80
87
|
|
|
81
88
|
## Configuration
|
|
82
89
|
|
|
File without changes
|
{the37lab_authlib-0.1.1750836881 → the37lab_authlib-0.1.1750837371}/src/the37lab_authlib/__init__.py
RENAMED
|
File without changes
|
{the37lab_authlib-0.1.1750836881 → the37lab_authlib-0.1.1750837371}/src/the37lab_authlib/db.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{the37lab_authlib-0.1.1750836881 → the37lab_authlib-0.1.1750837371}/src/the37lab_authlib/models.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|