the37lab-authlib 0.1.1751369506__tar.gz → 0.1.1751371611__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.1751369506 → the37lab_authlib-0.1.1751371611}/PKG-INFO +16 -1
- {the37lab_authlib-0.1.1751369506 → the37lab_authlib-0.1.1751371611}/README.md +15 -0
- {the37lab_authlib-0.1.1751369506 → the37lab_authlib-0.1.1751371611}/pyproject.toml +1 -1
- {the37lab_authlib-0.1.1751369506 → the37lab_authlib-0.1.1751371611}/src/the37lab_authlib/auth.py +14 -0
- {the37lab_authlib-0.1.1751369506 → the37lab_authlib-0.1.1751371611}/src/the37lab_authlib.egg-info/PKG-INFO +16 -1
- {the37lab_authlib-0.1.1751369506 → the37lab_authlib-0.1.1751371611}/setup.cfg +0 -0
- {the37lab_authlib-0.1.1751369506 → the37lab_authlib-0.1.1751371611}/src/the37lab_authlib/__init__.py +0 -0
- {the37lab_authlib-0.1.1751369506 → the37lab_authlib-0.1.1751371611}/src/the37lab_authlib/db.py +0 -0
- {the37lab_authlib-0.1.1751369506 → the37lab_authlib-0.1.1751371611}/src/the37lab_authlib/decorators.py +0 -0
- {the37lab_authlib-0.1.1751369506 → the37lab_authlib-0.1.1751371611}/src/the37lab_authlib/exceptions.py +0 -0
- {the37lab_authlib-0.1.1751369506 → the37lab_authlib-0.1.1751371611}/src/the37lab_authlib/models.py +0 -0
- {the37lab_authlib-0.1.1751369506 → the37lab_authlib-0.1.1751371611}/src/the37lab_authlib.egg-info/SOURCES.txt +0 -0
- {the37lab_authlib-0.1.1751369506 → the37lab_authlib-0.1.1751371611}/src/the37lab_authlib.egg-info/dependency_links.txt +0 -0
- {the37lab_authlib-0.1.1751369506 → the37lab_authlib-0.1.1751371611}/src/the37lab_authlib.egg-info/requires.txt +0 -0
- {the37lab_authlib-0.1.1751369506 → the37lab_authlib-0.1.1751371611}/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.1751371611
|
|
4
4
|
Summary: Python SDK for the Authlib
|
|
5
5
|
Author-email: the37lab <info@the37lab.com>
|
|
6
6
|
Classifier: Programming Language :: Python :: 3
|
|
@@ -42,6 +42,9 @@ A Python authentication library that provides JWT, OAuth2, and API token authent
|
|
|
42
42
|
- [API Token Override for Testing](#api-token-override-for-testing)
|
|
43
43
|
- [Usage](#usage)
|
|
44
44
|
- [Warning](#warning)
|
|
45
|
+
- [User Override for Testing](#user-override-for-testing)
|
|
46
|
+
- [Usage](#usage-1)
|
|
47
|
+
- [Warning](#warning-1)
|
|
45
48
|
|
|
46
49
|
## Installation
|
|
47
50
|
|
|
@@ -233,3 +236,15 @@ For testing purposes, you can bypass the database and provide a static mapping o
|
|
|
233
236
|
Replace `MYAPP` with your environment prefix.
|
|
234
237
|
|
|
235
238
|
**Warning:** This method is intended only for testing and development. Do not use this approach in production environments.
|
|
239
|
+
|
|
240
|
+
## User Override for Testing
|
|
241
|
+
|
|
242
|
+
For testing purposes, you can force all authentication to return a specific user by setting the `{PREFIX}USER_OVERRIDE` environment variable:
|
|
243
|
+
|
|
244
|
+
```bash
|
|
245
|
+
export MYAPP_USER_OVERRIDE="testuser"
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
If set, all requests will be authenticated as the specified user, regardless of any tokens or credentials provided. This cannot be combined with `api_tokens` or `db_dsn`.
|
|
249
|
+
|
|
250
|
+
**Warning:** This method is intended only for testing and development. Do not use this approach in production environments.
|
|
@@ -25,6 +25,9 @@ A Python authentication library that provides JWT, OAuth2, and API token authent
|
|
|
25
25
|
- [API Token Override for Testing](#api-token-override-for-testing)
|
|
26
26
|
- [Usage](#usage)
|
|
27
27
|
- [Warning](#warning)
|
|
28
|
+
- [User Override for Testing](#user-override-for-testing)
|
|
29
|
+
- [Usage](#usage-1)
|
|
30
|
+
- [Warning](#warning-1)
|
|
28
31
|
|
|
29
32
|
## Installation
|
|
30
33
|
|
|
@@ -216,3 +219,15 @@ For testing purposes, you can bypass the database and provide a static mapping o
|
|
|
216
219
|
Replace `MYAPP` with your environment prefix.
|
|
217
220
|
|
|
218
221
|
**Warning:** This method is intended only for testing and development. Do not use this approach in production environments.
|
|
222
|
+
|
|
223
|
+
## User Override for Testing
|
|
224
|
+
|
|
225
|
+
For testing purposes, you can force all authentication to return a specific user by setting the `{PREFIX}USER_OVERRIDE` environment variable:
|
|
226
|
+
|
|
227
|
+
```bash
|
|
228
|
+
export MYAPP_USER_OVERRIDE="testuser"
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
If set, all requests will be authenticated as the specified user, regardless of any tokens or credentials provided. This cannot be combined with `api_tokens` or `db_dsn`.
|
|
232
|
+
|
|
233
|
+
**Warning:** This method is intended only for testing and development. Do not use this approach in production environments.
|
|
@@ -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.1751371611"
|
|
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.1751369506 → the37lab_authlib-0.1.1751371611}/src/the37lab_authlib/auth.py
RENAMED
|
@@ -17,6 +17,7 @@ logger = logging.getLogger(__name__)
|
|
|
17
17
|
|
|
18
18
|
class AuthManager:
|
|
19
19
|
def __init__(self, app=None, db_dsn=None, jwt_secret=None, oauth_config=None, id_type='integer', environment_prefix=None, api_tokens=None):
|
|
20
|
+
self.user_override = None
|
|
20
21
|
if environment_prefix:
|
|
21
22
|
prefix = environment_prefix.upper() + '_'
|
|
22
23
|
db_dsn = os.getenv(f'{prefix}DATABASE_URL')
|
|
@@ -36,6 +37,11 @@ class AuthManager:
|
|
|
36
37
|
if ':' in entry:
|
|
37
38
|
key, user = entry.split(':', 1)
|
|
38
39
|
api_tokens[key.strip()] = user.strip()
|
|
40
|
+
user_override_env = os.getenv(f'{prefix}USER_OVERRIDE')
|
|
41
|
+
if user_override_env:
|
|
42
|
+
self.user_override = user_override_env
|
|
43
|
+
if self.user_override and (api_tokens or db_dsn):
|
|
44
|
+
raise ValueError('Cannot set user_override together with api_tokens or db_dsn')
|
|
39
45
|
if api_tokens and db_dsn:
|
|
40
46
|
raise ValueError('Cannot set both api_tokens and db_dsn')
|
|
41
47
|
self.api_tokens = api_tokens or None
|
|
@@ -131,6 +137,14 @@ class AuthManager:
|
|
|
131
137
|
raise AuthError('Invalid token format')
|
|
132
138
|
|
|
133
139
|
def _authenticate_request(self):
|
|
140
|
+
if self.user_override:
|
|
141
|
+
return {
|
|
142
|
+
'id': self.user_override,
|
|
143
|
+
'username': self.user_override,
|
|
144
|
+
'email': '',
|
|
145
|
+
'real_name': self.user_override,
|
|
146
|
+
'roles': []
|
|
147
|
+
}
|
|
134
148
|
auth_header = request.headers.get('Authorization')
|
|
135
149
|
api_token = request.headers.get('X-API-Token')
|
|
136
150
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: the37lab_authlib
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.1751371611
|
|
4
4
|
Summary: Python SDK for the Authlib
|
|
5
5
|
Author-email: the37lab <info@the37lab.com>
|
|
6
6
|
Classifier: Programming Language :: Python :: 3
|
|
@@ -42,6 +42,9 @@ A Python authentication library that provides JWT, OAuth2, and API token authent
|
|
|
42
42
|
- [API Token Override for Testing](#api-token-override-for-testing)
|
|
43
43
|
- [Usage](#usage)
|
|
44
44
|
- [Warning](#warning)
|
|
45
|
+
- [User Override for Testing](#user-override-for-testing)
|
|
46
|
+
- [Usage](#usage-1)
|
|
47
|
+
- [Warning](#warning-1)
|
|
45
48
|
|
|
46
49
|
## Installation
|
|
47
50
|
|
|
@@ -233,3 +236,15 @@ For testing purposes, you can bypass the database and provide a static mapping o
|
|
|
233
236
|
Replace `MYAPP` with your environment prefix.
|
|
234
237
|
|
|
235
238
|
**Warning:** This method is intended only for testing and development. Do not use this approach in production environments.
|
|
239
|
+
|
|
240
|
+
## User Override for Testing
|
|
241
|
+
|
|
242
|
+
For testing purposes, you can force all authentication to return a specific user by setting the `{PREFIX}USER_OVERRIDE` environment variable:
|
|
243
|
+
|
|
244
|
+
```bash
|
|
245
|
+
export MYAPP_USER_OVERRIDE="testuser"
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
If set, all requests will be authenticated as the specified user, regardless of any tokens or credentials provided. This cannot be combined with `api_tokens` or `db_dsn`.
|
|
249
|
+
|
|
250
|
+
**Warning:** This method is intended only for testing and development. Do not use this approach in production environments.
|
|
File without changes
|
{the37lab_authlib-0.1.1751369506 → the37lab_authlib-0.1.1751371611}/src/the37lab_authlib/__init__.py
RENAMED
|
File without changes
|
{the37lab_authlib-0.1.1751369506 → the37lab_authlib-0.1.1751371611}/src/the37lab_authlib/db.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{the37lab_authlib-0.1.1751369506 → the37lab_authlib-0.1.1751371611}/src/the37lab_authlib/models.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|