the37lab-authlib 0.1.1750840380__py3-none-any.whl → 0.1.1750840415__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 +11 -0
- {the37lab_authlib-0.1.1750840380.dist-info → the37lab_authlib-0.1.1750840415.dist-info}/METADATA +6 -6
- {the37lab_authlib-0.1.1750840380.dist-info → the37lab_authlib-0.1.1750840415.dist-info}/RECORD +5 -5
- {the37lab_authlib-0.1.1750840380.dist-info → the37lab_authlib-0.1.1750840415.dist-info}/WHEEL +0 -0
- {the37lab_authlib-0.1.1750840380.dist-info → the37lab_authlib-0.1.1750840415.dist-info}/top_level.txt +0 -0
the37lab_authlib/auth.py
CHANGED
|
@@ -252,6 +252,17 @@ class AuthManager:
|
|
|
252
252
|
except jwt.InvalidTokenError:
|
|
253
253
|
raise AuthError('Invalid refresh token', 401)
|
|
254
254
|
|
|
255
|
+
@bp.route('/api-tokens', methods=['POST'])
|
|
256
|
+
@handle_auth_errors
|
|
257
|
+
@self.require_auth
|
|
258
|
+
def create_api_token(requesting_user):
|
|
259
|
+
name = request.json.get('name')
|
|
260
|
+
if not name:
|
|
261
|
+
raise AuthError('Token name required', 400)
|
|
262
|
+
|
|
263
|
+
token = self.create_api_token(requesting_user['id'], name)
|
|
264
|
+
return jsonify({'token': token.token})
|
|
265
|
+
|
|
255
266
|
@bp.route('/api-tokens/validate', methods=['GET'])
|
|
256
267
|
@handle_auth_errors
|
|
257
268
|
@self.require_auth
|
{the37lab_authlib-0.1.1750840380.dist-info → the37lab_authlib-0.1.1750840415.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.1750840415
|
|
4
4
|
Summary: Python SDK for the Authlib
|
|
5
5
|
Author-email: the37lab <info@the37lab.com>
|
|
6
6
|
Classifier: Programming Language :: Python :: 3
|
|
@@ -50,7 +50,7 @@ pip install -e .
|
|
|
50
50
|
|
|
51
51
|
```python
|
|
52
52
|
from flask import Flask
|
|
53
|
-
from authlib import AuthManager
|
|
53
|
+
from authlib import AuthManager, require_auth
|
|
54
54
|
|
|
55
55
|
app = Flask(__name__)
|
|
56
56
|
|
|
@@ -67,7 +67,7 @@ auth = AuthManager(
|
|
|
67
67
|
)
|
|
68
68
|
|
|
69
69
|
@app.route("/protected")
|
|
70
|
-
@
|
|
70
|
+
@require_auth(roles=["admin"])
|
|
71
71
|
def protected_route():
|
|
72
72
|
return "Protected content"
|
|
73
73
|
```
|
|
@@ -126,8 +126,8 @@ def protected_route():
|
|
|
126
126
|
|
|
127
127
|
### API Tokens
|
|
128
128
|
- `POST /api/v1/users/{user}/api-tokens` - Create API token
|
|
129
|
-
- **Request:** `{ "name": "string", "
|
|
130
|
-
- **Response:** `{ "token": "string", "id": "uuid",
|
|
129
|
+
- **Request:** `{ "name": "string", "scopes": [ ... ] }`
|
|
130
|
+
- **Response:** `{ "token": "string", "id": "uuid", ... }`
|
|
131
131
|
- `GET /api/v1/users/{user}/api-tokens` - List API tokens
|
|
132
132
|
- **Response:** `[ { "id": "uuid", "name": "string", ... } ]`
|
|
133
133
|
- `DELETE /api/v1/users/{user}/api-tokens/{token_id}` - Delete API token
|
|
@@ -144,7 +144,7 @@ def protected_route():
|
|
|
144
144
|
- Get redirect URL from `/api/v1/users/login/oauth`.
|
|
145
145
|
- Complete OAuth flow via `/api/v1/users/login/oauth2callback`.
|
|
146
146
|
4. **Protected Routes:**
|
|
147
|
-
- Use `@
|
|
147
|
+
- Use `@require_auth()` decorator to protect Flask routes.
|
|
148
148
|
|
|
149
149
|
## User Object
|
|
150
150
|
|
{the37lab_authlib-0.1.1750840380.dist-info → the37lab_authlib-0.1.1750840415.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=dQkE6z9GZZpnl0nfqulcveho8W5lM95XUBLmtE-5JIc,20660
|
|
3
3
|
the37lab_authlib/db.py,sha256=fTXxnfju0lmbFGPVbXpTMeDmJMeBgURVZTndyxyRyCc,2734
|
|
4
4
|
the37lab_authlib/decorators.py,sha256=AEQfix31fHUZvhEZd4Ud8Zh2KBGjV6O_braiPL-BU7w,1219
|
|
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.1750840415.dist-info/METADATA,sha256=VVfAVdbm_v4u0-7_f7V0mvcumU-iJZPzkUgRqgfP2c4,5645
|
|
8
|
+
the37lab_authlib-0.1.1750840415.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
9
|
+
the37lab_authlib-0.1.1750840415.dist-info/top_level.txt,sha256=6Jmxw4UeLrhfJXgRKbXWY4OhxRSaMs0dKKhNCGWWSwc,17
|
|
10
|
+
the37lab_authlib-0.1.1750840415.dist-info/RECORD,,
|
{the37lab_authlib-0.1.1750840380.dist-info → the37lab_authlib-0.1.1750840415.dist-info}/WHEEL
RENAMED
|
File without changes
|
|
File without changes
|