the37lab-authlib 0.1.1750840380__tar.gz → 0.1.1750840398__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.1750840380 → the37lab_authlib-0.1.1750840398}/PKG-INFO +3 -3
  2. {the37lab_authlib-0.1.1750840380 → the37lab_authlib-0.1.1750840398}/README.md +2 -2
  3. {the37lab_authlib-0.1.1750840380 → the37lab_authlib-0.1.1750840398}/pyproject.toml +1 -1
  4. {the37lab_authlib-0.1.1750840380 → the37lab_authlib-0.1.1750840398}/src/the37lab_authlib/auth.py +16 -0
  5. {the37lab_authlib-0.1.1750840380 → the37lab_authlib-0.1.1750840398}/src/the37lab_authlib.egg-info/PKG-INFO +3 -3
  6. {the37lab_authlib-0.1.1750840380 → the37lab_authlib-0.1.1750840398}/setup.cfg +0 -0
  7. {the37lab_authlib-0.1.1750840380 → the37lab_authlib-0.1.1750840398}/src/the37lab_authlib/__init__.py +0 -0
  8. {the37lab_authlib-0.1.1750840380 → the37lab_authlib-0.1.1750840398}/src/the37lab_authlib/db.py +0 -0
  9. {the37lab_authlib-0.1.1750840380 → the37lab_authlib-0.1.1750840398}/src/the37lab_authlib/decorators.py +0 -0
  10. {the37lab_authlib-0.1.1750840380 → the37lab_authlib-0.1.1750840398}/src/the37lab_authlib/exceptions.py +0 -0
  11. {the37lab_authlib-0.1.1750840380 → the37lab_authlib-0.1.1750840398}/src/the37lab_authlib/models.py +0 -0
  12. {the37lab_authlib-0.1.1750840380 → the37lab_authlib-0.1.1750840398}/src/the37lab_authlib.egg-info/SOURCES.txt +0 -0
  13. {the37lab_authlib-0.1.1750840380 → the37lab_authlib-0.1.1750840398}/src/the37lab_authlib.egg-info/dependency_links.txt +0 -0
  14. {the37lab_authlib-0.1.1750840380 → the37lab_authlib-0.1.1750840398}/src/the37lab_authlib.egg-info/requires.txt +0 -0
  15. {the37lab_authlib-0.1.1750840380 → the37lab_authlib-0.1.1750840398}/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.1750840380
3
+ Version: 0.1.1750840398
4
4
  Summary: Python SDK for the Authlib
5
5
  Author-email: the37lab <info@the37lab.com>
6
6
  Classifier: Programming Language :: Python :: 3
@@ -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", "expires_in_days": number | null }`
130
- - **Response:** `{ "token": "string", "id": "uuid", "name": "string", "created_at": "timestamp", "expires_at": "timestamp | null" }`
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
@@ -109,8 +109,8 @@ def protected_route():
109
109
 
110
110
  ### API Tokens
111
111
  - `POST /api/v1/users/{user}/api-tokens` - Create API token
112
- - **Request:** `{ "name": "string", "expires_in_days": number | null }`
113
- - **Response:** `{ "token": "string", "id": "uuid", "name": "string", "created_at": "timestamp", "expires_at": "timestamp | null" }`
112
+ - **Request:** `{ "name": "string", "scopes": [ ... ] }`
113
+ - **Response:** `{ "token": "string", "id": "uuid", ... }`
114
114
  - `GET /api/v1/users/{user}/api-tokens` - List API tokens
115
115
  - **Response:** `[ { "id": "uuid", "name": "string", ... } ]`
116
116
  - `DELETE /api/v1/users/{user}/api-tokens/{token_id}` - Delete API token
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "the37lab_authlib"
7
- version = "0.1.1750840380"
7
+ version = "0.1.1750840398"
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"]
@@ -128,6 +128,11 @@ class AuthManager:
128
128
  def init_app(self, app):
129
129
  app.auth_manager = self
130
130
  app.register_blueprint(self.create_blueprint())
131
+ @app.errorhandler(AuthError)
132
+ def handle_auth_error(e):
133
+ response = jsonify(e.to_dict())
134
+ response.status_code = e.status_code
135
+ return response
131
136
 
132
137
  def create_blueprint(self):
133
138
  bp = Blueprint('auth', __name__, url_prefix='/api/v1/users')
@@ -252,6 +257,17 @@ class AuthManager:
252
257
  except jwt.InvalidTokenError:
253
258
  raise AuthError('Invalid refresh token', 401)
254
259
 
260
+ @bp.route('/api-tokens', methods=['POST'])
261
+ @handle_auth_errors
262
+ @self.require_auth
263
+ def create_api_token(requesting_user):
264
+ name = request.json.get('name')
265
+ if not name:
266
+ raise AuthError('Token name required', 400)
267
+
268
+ token = self.create_api_token(requesting_user['id'], name)
269
+ return jsonify({'token': token.token})
270
+
255
271
  @bp.route('/api-tokens/validate', methods=['GET'])
256
272
  @handle_auth_errors
257
273
  @self.require_auth
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: the37lab_authlib
3
- Version: 0.1.1750840380
3
+ Version: 0.1.1750840398
4
4
  Summary: Python SDK for the Authlib
5
5
  Author-email: the37lab <info@the37lab.com>
6
6
  Classifier: Programming Language :: Python :: 3
@@ -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", "expires_in_days": number | null }`
130
- - **Response:** `{ "token": "string", "id": "uuid", "name": "string", "created_at": "timestamp", "expires_at": "timestamp | null" }`
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