the37lab-authlib 0.1.1750143654__tar.gz → 0.1.1750156111__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 (18) hide show
  1. the37lab_authlib-0.1.1750156111/PKG-INFO +191 -0
  2. the37lab_authlib-0.1.1750156111/README.md +174 -0
  3. {the37lab_authlib-0.1.1750143654 → the37lab_authlib-0.1.1750156111}/pyproject.toml +1 -1
  4. the37lab_authlib-0.1.1750156111/src/the37lab_authlib.egg-info/PKG-INFO +191 -0
  5. the37lab_authlib-0.1.1750143654/PKG-INFO +0 -114
  6. the37lab_authlib-0.1.1750143654/README.md +0 -97
  7. the37lab_authlib-0.1.1750143654/src/the37lab_authlib.egg-info/PKG-INFO +0 -114
  8. {the37lab_authlib-0.1.1750143654 → the37lab_authlib-0.1.1750156111}/setup.cfg +0 -0
  9. {the37lab_authlib-0.1.1750143654 → the37lab_authlib-0.1.1750156111}/src/the37lab_authlib/__init__.py +0 -0
  10. {the37lab_authlib-0.1.1750143654 → the37lab_authlib-0.1.1750156111}/src/the37lab_authlib/auth.py +0 -0
  11. {the37lab_authlib-0.1.1750143654 → the37lab_authlib-0.1.1750156111}/src/the37lab_authlib/db.py +0 -0
  12. {the37lab_authlib-0.1.1750143654 → the37lab_authlib-0.1.1750156111}/src/the37lab_authlib/decorators.py +0 -0
  13. {the37lab_authlib-0.1.1750143654 → the37lab_authlib-0.1.1750156111}/src/the37lab_authlib/exceptions.py +0 -0
  14. {the37lab_authlib-0.1.1750143654 → the37lab_authlib-0.1.1750156111}/src/the37lab_authlib/models.py +0 -0
  15. {the37lab_authlib-0.1.1750143654 → the37lab_authlib-0.1.1750156111}/src/the37lab_authlib.egg-info/SOURCES.txt +0 -0
  16. {the37lab_authlib-0.1.1750143654 → the37lab_authlib-0.1.1750156111}/src/the37lab_authlib.egg-info/dependency_links.txt +0 -0
  17. {the37lab_authlib-0.1.1750143654 → the37lab_authlib-0.1.1750156111}/src/the37lab_authlib.egg-info/requires.txt +0 -0
  18. {the37lab_authlib-0.1.1750143654 → the37lab_authlib-0.1.1750156111}/src/the37lab_authlib.egg-info/top_level.txt +0 -0
@@ -0,0 +1,191 @@
1
+ Metadata-Version: 2.4
2
+ Name: the37lab_authlib
3
+ Version: 0.1.1750156111
4
+ Summary: Python SDK for the Authlib
5
+ Author-email: the37lab <info@the37lab.com>
6
+ Classifier: Programming Language :: Python :: 3
7
+ Classifier: Operating System :: OS Independent
8
+ Requires-Python: >=3.9
9
+ Description-Content-Type: text/markdown
10
+ Requires-Dist: flask
11
+ Requires-Dist: psycopg2-binary
12
+ Requires-Dist: pyjwt
13
+ Requires-Dist: python-dotenv
14
+ Requires-Dist: requests
15
+ Requires-Dist: authlib
16
+ Requires-Dist: bcrypt
17
+
18
+ # AuthLib
19
+
20
+ A Python authentication library that provides JWT, OAuth2, and API token authentication with PostgreSQL backend. This library is designed for seamless integration with Flask applications and provides a robust set of endpoints and utilities for user management, authentication, and API token handling.
21
+
22
+ ## Table of Contents
23
+ - [AuthLib](#authlib)
24
+ - [Table of Contents](#table-of-contents)
25
+ - [Installation](#installation)
26
+ - [Quick Start](#quick-start)
27
+ - [Configuration](#configuration)
28
+ - [Required Parameters](#required-parameters)
29
+ - [Optional Parameters](#optional-parameters)
30
+ - [Example `oauth_config`:](#example-oauth_config)
31
+ - [API Endpoints](#api-endpoints)
32
+ - [Authentication](#authentication)
33
+ - [User Management](#user-management)
34
+ - [API Tokens](#api-tokens)
35
+ - [Authentication Flow](#authentication-flow)
36
+ - [User Object](#user-object)
37
+ - [Token Management](#token-management)
38
+ - [Development](#development)
39
+ - [Setup](#setup)
40
+ - [Database Setup](#database-setup)
41
+ - [Running Tests](#running-tests)
42
+
43
+ ## Installation
44
+
45
+ ```bash
46
+ pip install -e .
47
+ ```
48
+
49
+ ## Quick Start
50
+
51
+ ```python
52
+ from flask import Flask
53
+ from authlib import AuthManager
54
+
55
+ app = Flask(__name__)
56
+
57
+ auth = AuthManager(
58
+ app=app,
59
+ db_dsn="postgresql://user:pass@localhost/dbname",
60
+ jwt_secret="your-secret-key",
61
+ oauth_config={
62
+ "google": {
63
+ "client_id": "your-client-id",
64
+ "client_secret": "your-client-secret"
65
+ }
66
+ }
67
+ )
68
+
69
+ @app.route("/protected")
70
+ @auth.require_auth(roles=["admin"])
71
+ def protected_route():
72
+ return "Protected content"
73
+ ```
74
+
75
+ ## Configuration
76
+
77
+ ### Required Parameters
78
+ - `app`: Flask application instance
79
+ - `db_dsn`: PostgreSQL connection string
80
+ - `jwt_secret`: Secret key for JWT signing
81
+
82
+ ### Optional Parameters
83
+ - `oauth_config`: Dictionary of OAuth provider configurations (see below)
84
+ - `token_expiry`: JWT token expiry time in seconds (default: 3600)
85
+ - `refresh_token_expiry`: Refresh token expiry time in seconds (default: 2592000)
86
+
87
+ #### Example `oauth_config`:
88
+ ```python
89
+ {
90
+ "google": {
91
+ "client_id": "...",
92
+ "client_secret": "..."
93
+ },
94
+ "github": {
95
+ "client_id": "...",
96
+ "client_secret": "..."
97
+ }
98
+ }
99
+ ```
100
+
101
+ ## API Endpoints
102
+
103
+ ### Authentication
104
+ - `POST /v1/users/login` - Login with username/password
105
+ - **Request:** `{ "username": "string", "password": "string" }`
106
+ - **Response:** `{ "token": "jwt", "refresh_token": "jwt", "user": { ... } }`
107
+ - `POST /v1/users/login/oauth` - Get OAuth redirect URL
108
+ - **Request:** `{ "provider": "google|github|..." }`
109
+ - **Response:** `{ "redirect_url": "string" }`
110
+ - `GET /v1/users/login/oauth2callback` - OAuth callback
111
+ - **Query Params:** `code`, `state`, `provider`
112
+ - **Response:** `{ "token": "jwt", "refresh_token": "jwt", "user": { ... } }`
113
+ - `POST /v1/users/token-refresh` - Refresh JWT token
114
+ - **Request:** `{ "refresh_token": "jwt" }`
115
+ - **Response:** `{ "token": "jwt", "refresh_token": "jwt" }`
116
+
117
+ ### User Management
118
+ - `POST /v1/users/register` - Register new user
119
+ - **Request:** `{ "username": "string", "password": "string", "email": "string", ... }`
120
+ - **Response:** `{ "user": { ... }, "token": "jwt", "refresh_token": "jwt" }`
121
+ - `GET /v1/users/login/profile` - Get user profile
122
+ - **Auth:** Bearer JWT
123
+ - **Response:** `{ "user": { ... } }`
124
+ - `GET /v1/users/roles` - Get available roles
125
+ - **Response:** `[ "admin", "user", ... ]`
126
+
127
+ ### API Tokens
128
+ - `POST /v1/users/{user}/api-tokens` - Create API token
129
+ - **Request:** `{ "name": "string", "scopes": [ ... ] }`
130
+ - **Response:** `{ "token": "string", "id": "uuid", ... }`
131
+ - `GET /v1/users/{user}/api-tokens` - List API tokens
132
+ - **Response:** `[ { "id": "uuid", "name": "string", ... } ]`
133
+ - `DELETE /v1/users/{user}/api-tokens/{token_id}` - Delete API token
134
+ - **Response:** `{ "success": true }`
135
+
136
+ ## Authentication Flow
137
+
138
+ 1. **Login:**
139
+ - User submits credentials to `/v1/users/login`.
140
+ - Receives JWT and refresh token.
141
+ 2. **Token Refresh:**
142
+ - Use `/v1/users/token-refresh` with refresh token to get new JWT.
143
+ 3. **OAuth:**
144
+ - Get redirect URL from `/v1/users/login/oauth`.
145
+ - Complete OAuth flow via `/v1/users/login/oauth2callback`.
146
+ 4. **Protected Routes:**
147
+ - Use `@auth.require_auth()` decorator to protect Flask routes.
148
+
149
+ ## User Object
150
+
151
+ The user object returned by the API typically includes:
152
+ ```json
153
+ {
154
+ "id": "uuid",
155
+ "username": "string",
156
+ "email": "string",
157
+ "roles": ["user", "admin"],
158
+ "created_at": "timestamp",
159
+ "last_login": "timestamp"
160
+ }
161
+ ```
162
+
163
+ ## Token Management
164
+ - **JWT:** Used for authenticating API requests. Include in `Authorization: Bearer <token>` header.
165
+ - **Refresh Token:** Used to obtain new JWTs without re-authenticating.
166
+ - **API Tokens:** Long-lived tokens for programmatic access, managed per user.
167
+
168
+ ## Development
169
+
170
+ ### Setup
171
+ 1. Clone the repository
172
+ 2. Create virtual environment:
173
+ ```bash
174
+ python -m venv venv
175
+ venv\Scripts\activate
176
+ ```
177
+ 3. Install dependencies:
178
+ ```bash
179
+ pip install -e ".[dev]"
180
+ ```
181
+
182
+ ### Database Setup
183
+ ```bash
184
+ createdb authlib
185
+ python -m authlib.cli db init
186
+ ```
187
+
188
+ ### Running Tests
189
+ ```bash
190
+ pytest
191
+ ```
@@ -0,0 +1,174 @@
1
+ # AuthLib
2
+
3
+ A Python authentication library that provides JWT, OAuth2, and API token authentication with PostgreSQL backend. This library is designed for seamless integration with Flask applications and provides a robust set of endpoints and utilities for user management, authentication, and API token handling.
4
+
5
+ ## Table of Contents
6
+ - [AuthLib](#authlib)
7
+ - [Table of Contents](#table-of-contents)
8
+ - [Installation](#installation)
9
+ - [Quick Start](#quick-start)
10
+ - [Configuration](#configuration)
11
+ - [Required Parameters](#required-parameters)
12
+ - [Optional Parameters](#optional-parameters)
13
+ - [Example `oauth_config`:](#example-oauth_config)
14
+ - [API Endpoints](#api-endpoints)
15
+ - [Authentication](#authentication)
16
+ - [User Management](#user-management)
17
+ - [API Tokens](#api-tokens)
18
+ - [Authentication Flow](#authentication-flow)
19
+ - [User Object](#user-object)
20
+ - [Token Management](#token-management)
21
+ - [Development](#development)
22
+ - [Setup](#setup)
23
+ - [Database Setup](#database-setup)
24
+ - [Running Tests](#running-tests)
25
+
26
+ ## Installation
27
+
28
+ ```bash
29
+ pip install -e .
30
+ ```
31
+
32
+ ## Quick Start
33
+
34
+ ```python
35
+ from flask import Flask
36
+ from authlib import AuthManager
37
+
38
+ app = Flask(__name__)
39
+
40
+ auth = AuthManager(
41
+ app=app,
42
+ db_dsn="postgresql://user:pass@localhost/dbname",
43
+ jwt_secret="your-secret-key",
44
+ oauth_config={
45
+ "google": {
46
+ "client_id": "your-client-id",
47
+ "client_secret": "your-client-secret"
48
+ }
49
+ }
50
+ )
51
+
52
+ @app.route("/protected")
53
+ @auth.require_auth(roles=["admin"])
54
+ def protected_route():
55
+ return "Protected content"
56
+ ```
57
+
58
+ ## Configuration
59
+
60
+ ### Required Parameters
61
+ - `app`: Flask application instance
62
+ - `db_dsn`: PostgreSQL connection string
63
+ - `jwt_secret`: Secret key for JWT signing
64
+
65
+ ### Optional Parameters
66
+ - `oauth_config`: Dictionary of OAuth provider configurations (see below)
67
+ - `token_expiry`: JWT token expiry time in seconds (default: 3600)
68
+ - `refresh_token_expiry`: Refresh token expiry time in seconds (default: 2592000)
69
+
70
+ #### Example `oauth_config`:
71
+ ```python
72
+ {
73
+ "google": {
74
+ "client_id": "...",
75
+ "client_secret": "..."
76
+ },
77
+ "github": {
78
+ "client_id": "...",
79
+ "client_secret": "..."
80
+ }
81
+ }
82
+ ```
83
+
84
+ ## API Endpoints
85
+
86
+ ### Authentication
87
+ - `POST /v1/users/login` - Login with username/password
88
+ - **Request:** `{ "username": "string", "password": "string" }`
89
+ - **Response:** `{ "token": "jwt", "refresh_token": "jwt", "user": { ... } }`
90
+ - `POST /v1/users/login/oauth` - Get OAuth redirect URL
91
+ - **Request:** `{ "provider": "google|github|..." }`
92
+ - **Response:** `{ "redirect_url": "string" }`
93
+ - `GET /v1/users/login/oauth2callback` - OAuth callback
94
+ - **Query Params:** `code`, `state`, `provider`
95
+ - **Response:** `{ "token": "jwt", "refresh_token": "jwt", "user": { ... } }`
96
+ - `POST /v1/users/token-refresh` - Refresh JWT token
97
+ - **Request:** `{ "refresh_token": "jwt" }`
98
+ - **Response:** `{ "token": "jwt", "refresh_token": "jwt" }`
99
+
100
+ ### User Management
101
+ - `POST /v1/users/register` - Register new user
102
+ - **Request:** `{ "username": "string", "password": "string", "email": "string", ... }`
103
+ - **Response:** `{ "user": { ... }, "token": "jwt", "refresh_token": "jwt" }`
104
+ - `GET /v1/users/login/profile` - Get user profile
105
+ - **Auth:** Bearer JWT
106
+ - **Response:** `{ "user": { ... } }`
107
+ - `GET /v1/users/roles` - Get available roles
108
+ - **Response:** `[ "admin", "user", ... ]`
109
+
110
+ ### API Tokens
111
+ - `POST /v1/users/{user}/api-tokens` - Create API token
112
+ - **Request:** `{ "name": "string", "scopes": [ ... ] }`
113
+ - **Response:** `{ "token": "string", "id": "uuid", ... }`
114
+ - `GET /v1/users/{user}/api-tokens` - List API tokens
115
+ - **Response:** `[ { "id": "uuid", "name": "string", ... } ]`
116
+ - `DELETE /v1/users/{user}/api-tokens/{token_id}` - Delete API token
117
+ - **Response:** `{ "success": true }`
118
+
119
+ ## Authentication Flow
120
+
121
+ 1. **Login:**
122
+ - User submits credentials to `/v1/users/login`.
123
+ - Receives JWT and refresh token.
124
+ 2. **Token Refresh:**
125
+ - Use `/v1/users/token-refresh` with refresh token to get new JWT.
126
+ 3. **OAuth:**
127
+ - Get redirect URL from `/v1/users/login/oauth`.
128
+ - Complete OAuth flow via `/v1/users/login/oauth2callback`.
129
+ 4. **Protected Routes:**
130
+ - Use `@auth.require_auth()` decorator to protect Flask routes.
131
+
132
+ ## User Object
133
+
134
+ The user object returned by the API typically includes:
135
+ ```json
136
+ {
137
+ "id": "uuid",
138
+ "username": "string",
139
+ "email": "string",
140
+ "roles": ["user", "admin"],
141
+ "created_at": "timestamp",
142
+ "last_login": "timestamp"
143
+ }
144
+ ```
145
+
146
+ ## Token Management
147
+ - **JWT:** Used for authenticating API requests. Include in `Authorization: Bearer <token>` header.
148
+ - **Refresh Token:** Used to obtain new JWTs without re-authenticating.
149
+ - **API Tokens:** Long-lived tokens for programmatic access, managed per user.
150
+
151
+ ## Development
152
+
153
+ ### Setup
154
+ 1. Clone the repository
155
+ 2. Create virtual environment:
156
+ ```bash
157
+ python -m venv venv
158
+ venv\Scripts\activate
159
+ ```
160
+ 3. Install dependencies:
161
+ ```bash
162
+ pip install -e ".[dev]"
163
+ ```
164
+
165
+ ### Database Setup
166
+ ```bash
167
+ createdb authlib
168
+ python -m authlib.cli db init
169
+ ```
170
+
171
+ ### Running Tests
172
+ ```bash
173
+ pytest
174
+ ```
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "the37lab_authlib"
7
- version = "0.1.1750143654"
7
+ version = "0.1.1750156111"
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"]
@@ -0,0 +1,191 @@
1
+ Metadata-Version: 2.4
2
+ Name: the37lab_authlib
3
+ Version: 0.1.1750156111
4
+ Summary: Python SDK for the Authlib
5
+ Author-email: the37lab <info@the37lab.com>
6
+ Classifier: Programming Language :: Python :: 3
7
+ Classifier: Operating System :: OS Independent
8
+ Requires-Python: >=3.9
9
+ Description-Content-Type: text/markdown
10
+ Requires-Dist: flask
11
+ Requires-Dist: psycopg2-binary
12
+ Requires-Dist: pyjwt
13
+ Requires-Dist: python-dotenv
14
+ Requires-Dist: requests
15
+ Requires-Dist: authlib
16
+ Requires-Dist: bcrypt
17
+
18
+ # AuthLib
19
+
20
+ A Python authentication library that provides JWT, OAuth2, and API token authentication with PostgreSQL backend. This library is designed for seamless integration with Flask applications and provides a robust set of endpoints and utilities for user management, authentication, and API token handling.
21
+
22
+ ## Table of Contents
23
+ - [AuthLib](#authlib)
24
+ - [Table of Contents](#table-of-contents)
25
+ - [Installation](#installation)
26
+ - [Quick Start](#quick-start)
27
+ - [Configuration](#configuration)
28
+ - [Required Parameters](#required-parameters)
29
+ - [Optional Parameters](#optional-parameters)
30
+ - [Example `oauth_config`:](#example-oauth_config)
31
+ - [API Endpoints](#api-endpoints)
32
+ - [Authentication](#authentication)
33
+ - [User Management](#user-management)
34
+ - [API Tokens](#api-tokens)
35
+ - [Authentication Flow](#authentication-flow)
36
+ - [User Object](#user-object)
37
+ - [Token Management](#token-management)
38
+ - [Development](#development)
39
+ - [Setup](#setup)
40
+ - [Database Setup](#database-setup)
41
+ - [Running Tests](#running-tests)
42
+
43
+ ## Installation
44
+
45
+ ```bash
46
+ pip install -e .
47
+ ```
48
+
49
+ ## Quick Start
50
+
51
+ ```python
52
+ from flask import Flask
53
+ from authlib import AuthManager
54
+
55
+ app = Flask(__name__)
56
+
57
+ auth = AuthManager(
58
+ app=app,
59
+ db_dsn="postgresql://user:pass@localhost/dbname",
60
+ jwt_secret="your-secret-key",
61
+ oauth_config={
62
+ "google": {
63
+ "client_id": "your-client-id",
64
+ "client_secret": "your-client-secret"
65
+ }
66
+ }
67
+ )
68
+
69
+ @app.route("/protected")
70
+ @auth.require_auth(roles=["admin"])
71
+ def protected_route():
72
+ return "Protected content"
73
+ ```
74
+
75
+ ## Configuration
76
+
77
+ ### Required Parameters
78
+ - `app`: Flask application instance
79
+ - `db_dsn`: PostgreSQL connection string
80
+ - `jwt_secret`: Secret key for JWT signing
81
+
82
+ ### Optional Parameters
83
+ - `oauth_config`: Dictionary of OAuth provider configurations (see below)
84
+ - `token_expiry`: JWT token expiry time in seconds (default: 3600)
85
+ - `refresh_token_expiry`: Refresh token expiry time in seconds (default: 2592000)
86
+
87
+ #### Example `oauth_config`:
88
+ ```python
89
+ {
90
+ "google": {
91
+ "client_id": "...",
92
+ "client_secret": "..."
93
+ },
94
+ "github": {
95
+ "client_id": "...",
96
+ "client_secret": "..."
97
+ }
98
+ }
99
+ ```
100
+
101
+ ## API Endpoints
102
+
103
+ ### Authentication
104
+ - `POST /v1/users/login` - Login with username/password
105
+ - **Request:** `{ "username": "string", "password": "string" }`
106
+ - **Response:** `{ "token": "jwt", "refresh_token": "jwt", "user": { ... } }`
107
+ - `POST /v1/users/login/oauth` - Get OAuth redirect URL
108
+ - **Request:** `{ "provider": "google|github|..." }`
109
+ - **Response:** `{ "redirect_url": "string" }`
110
+ - `GET /v1/users/login/oauth2callback` - OAuth callback
111
+ - **Query Params:** `code`, `state`, `provider`
112
+ - **Response:** `{ "token": "jwt", "refresh_token": "jwt", "user": { ... } }`
113
+ - `POST /v1/users/token-refresh` - Refresh JWT token
114
+ - **Request:** `{ "refresh_token": "jwt" }`
115
+ - **Response:** `{ "token": "jwt", "refresh_token": "jwt" }`
116
+
117
+ ### User Management
118
+ - `POST /v1/users/register` - Register new user
119
+ - **Request:** `{ "username": "string", "password": "string", "email": "string", ... }`
120
+ - **Response:** `{ "user": { ... }, "token": "jwt", "refresh_token": "jwt" }`
121
+ - `GET /v1/users/login/profile` - Get user profile
122
+ - **Auth:** Bearer JWT
123
+ - **Response:** `{ "user": { ... } }`
124
+ - `GET /v1/users/roles` - Get available roles
125
+ - **Response:** `[ "admin", "user", ... ]`
126
+
127
+ ### API Tokens
128
+ - `POST /v1/users/{user}/api-tokens` - Create API token
129
+ - **Request:** `{ "name": "string", "scopes": [ ... ] }`
130
+ - **Response:** `{ "token": "string", "id": "uuid", ... }`
131
+ - `GET /v1/users/{user}/api-tokens` - List API tokens
132
+ - **Response:** `[ { "id": "uuid", "name": "string", ... } ]`
133
+ - `DELETE /v1/users/{user}/api-tokens/{token_id}` - Delete API token
134
+ - **Response:** `{ "success": true }`
135
+
136
+ ## Authentication Flow
137
+
138
+ 1. **Login:**
139
+ - User submits credentials to `/v1/users/login`.
140
+ - Receives JWT and refresh token.
141
+ 2. **Token Refresh:**
142
+ - Use `/v1/users/token-refresh` with refresh token to get new JWT.
143
+ 3. **OAuth:**
144
+ - Get redirect URL from `/v1/users/login/oauth`.
145
+ - Complete OAuth flow via `/v1/users/login/oauth2callback`.
146
+ 4. **Protected Routes:**
147
+ - Use `@auth.require_auth()` decorator to protect Flask routes.
148
+
149
+ ## User Object
150
+
151
+ The user object returned by the API typically includes:
152
+ ```json
153
+ {
154
+ "id": "uuid",
155
+ "username": "string",
156
+ "email": "string",
157
+ "roles": ["user", "admin"],
158
+ "created_at": "timestamp",
159
+ "last_login": "timestamp"
160
+ }
161
+ ```
162
+
163
+ ## Token Management
164
+ - **JWT:** Used for authenticating API requests. Include in `Authorization: Bearer <token>` header.
165
+ - **Refresh Token:** Used to obtain new JWTs without re-authenticating.
166
+ - **API Tokens:** Long-lived tokens for programmatic access, managed per user.
167
+
168
+ ## Development
169
+
170
+ ### Setup
171
+ 1. Clone the repository
172
+ 2. Create virtual environment:
173
+ ```bash
174
+ python -m venv venv
175
+ venv\Scripts\activate
176
+ ```
177
+ 3. Install dependencies:
178
+ ```bash
179
+ pip install -e ".[dev]"
180
+ ```
181
+
182
+ ### Database Setup
183
+ ```bash
184
+ createdb authlib
185
+ python -m authlib.cli db init
186
+ ```
187
+
188
+ ### Running Tests
189
+ ```bash
190
+ pytest
191
+ ```
@@ -1,114 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: the37lab_authlib
3
- Version: 0.1.1750143654
4
- Summary: Python SDK for the Authlib
5
- Author-email: the37lab <info@the37lab.com>
6
- Classifier: Programming Language :: Python :: 3
7
- Classifier: Operating System :: OS Independent
8
- Requires-Python: >=3.9
9
- Description-Content-Type: text/markdown
10
- Requires-Dist: flask
11
- Requires-Dist: psycopg2-binary
12
- Requires-Dist: pyjwt
13
- Requires-Dist: python-dotenv
14
- Requires-Dist: requests
15
- Requires-Dist: authlib
16
- Requires-Dist: bcrypt
17
-
18
- # AuthLib
19
-
20
- A Python authentication library that provides JWT, OAuth2, and API token authentication with PostgreSQL backend.
21
-
22
- ## Table of Contents
23
- - [Installation](#installation)
24
- - [Quick Start](#quick-start)
25
- - [Configuration](#configuration)
26
- - [API Endpoints](#api-endpoints)
27
- - [Development](#development)
28
-
29
- ## Installation
30
-
31
- ```bash
32
- pip install -e .
33
- ```
34
-
35
- ## Quick Start
36
-
37
- ```python
38
- from flask import Flask
39
- from authlib import AuthManager
40
-
41
- app = Flask(__name__)
42
-
43
- auth = AuthManager(
44
- app=app,
45
- db_dsn="postgresql://user:pass@localhost/dbname",
46
- jwt_secret="your-secret-key",
47
- oauth_config={
48
- "google": {
49
- "client_id": "your-client-id",
50
- "client_secret": "your-client-secret"
51
- }
52
- }
53
- )
54
-
55
- @app.route("/protected")
56
- @auth.require_auth(roles=["admin"])
57
- def protected_route():
58
- return "Protected content"
59
- ```
60
-
61
- ## Configuration
62
-
63
- ### Required Parameters
64
- - `app`: Flask application instance
65
- - `db_dsn`: PostgreSQL connection string
66
- - `jwt_secret`: Secret key for JWT signing
67
-
68
- ### Optional Parameters
69
- - `oauth_config`: Dictionary of OAuth provider configurations
70
- - `token_expiry`: JWT token expiry time in seconds (default: 3600)
71
- - `refresh_token_expiry`: Refresh token expiry time in seconds (default: 2592000)
72
-
73
- ## API Endpoints
74
-
75
- ### Authentication
76
- - `POST /v1/users/login` - Login with username/password
77
- - `POST /v1/users/login/oauth` - Get OAuth redirect URL
78
- - `GET /v1/users/login/oauth2callback` - OAuth callback
79
- - `POST /v1/users/token-refresh` - Refresh JWT token
80
-
81
- ### User Management
82
- - `POST /v1/users/register` - Register new user
83
- - `GET /v1/users/login/profile` - Get user profile
84
- - `GET /v1/users/roles` - Get available roles
85
-
86
- ### API Tokens
87
- - `POST /v1/users/{user}/api-tokens` - Create API token
88
- - `GET /v1/users/{user}/api-tokens` - List API tokens
89
- - `DELETE /v1/users/{user}/api-tokens/{token_id}` - Delete API token
90
-
91
- ## Development
92
-
93
- ### Setup
94
- 1. Clone the repository
95
- 2. Create virtual environment:
96
- ```bash
97
- python -m venv venv
98
- venv\Scripts\activate
99
- ```
100
- 3. Install dependencies:
101
- ```bash
102
- pip install -e ".[dev]"
103
- ```
104
-
105
- ### Database Setup
106
- ```bash
107
- createdb authlib
108
- python -m authlib.cli db init
109
- ```
110
-
111
- ### Running Tests
112
- ```bash
113
- pytest
114
- ```
@@ -1,97 +0,0 @@
1
- # AuthLib
2
-
3
- A Python authentication library that provides JWT, OAuth2, and API token authentication with PostgreSQL backend.
4
-
5
- ## Table of Contents
6
- - [Installation](#installation)
7
- - [Quick Start](#quick-start)
8
- - [Configuration](#configuration)
9
- - [API Endpoints](#api-endpoints)
10
- - [Development](#development)
11
-
12
- ## Installation
13
-
14
- ```bash
15
- pip install -e .
16
- ```
17
-
18
- ## Quick Start
19
-
20
- ```python
21
- from flask import Flask
22
- from authlib import AuthManager
23
-
24
- app = Flask(__name__)
25
-
26
- auth = AuthManager(
27
- app=app,
28
- db_dsn="postgresql://user:pass@localhost/dbname",
29
- jwt_secret="your-secret-key",
30
- oauth_config={
31
- "google": {
32
- "client_id": "your-client-id",
33
- "client_secret": "your-client-secret"
34
- }
35
- }
36
- )
37
-
38
- @app.route("/protected")
39
- @auth.require_auth(roles=["admin"])
40
- def protected_route():
41
- return "Protected content"
42
- ```
43
-
44
- ## Configuration
45
-
46
- ### Required Parameters
47
- - `app`: Flask application instance
48
- - `db_dsn`: PostgreSQL connection string
49
- - `jwt_secret`: Secret key for JWT signing
50
-
51
- ### Optional Parameters
52
- - `oauth_config`: Dictionary of OAuth provider configurations
53
- - `token_expiry`: JWT token expiry time in seconds (default: 3600)
54
- - `refresh_token_expiry`: Refresh token expiry time in seconds (default: 2592000)
55
-
56
- ## API Endpoints
57
-
58
- ### Authentication
59
- - `POST /v1/users/login` - Login with username/password
60
- - `POST /v1/users/login/oauth` - Get OAuth redirect URL
61
- - `GET /v1/users/login/oauth2callback` - OAuth callback
62
- - `POST /v1/users/token-refresh` - Refresh JWT token
63
-
64
- ### User Management
65
- - `POST /v1/users/register` - Register new user
66
- - `GET /v1/users/login/profile` - Get user profile
67
- - `GET /v1/users/roles` - Get available roles
68
-
69
- ### API Tokens
70
- - `POST /v1/users/{user}/api-tokens` - Create API token
71
- - `GET /v1/users/{user}/api-tokens` - List API tokens
72
- - `DELETE /v1/users/{user}/api-tokens/{token_id}` - Delete API token
73
-
74
- ## Development
75
-
76
- ### Setup
77
- 1. Clone the repository
78
- 2. Create virtual environment:
79
- ```bash
80
- python -m venv venv
81
- venv\Scripts\activate
82
- ```
83
- 3. Install dependencies:
84
- ```bash
85
- pip install -e ".[dev]"
86
- ```
87
-
88
- ### Database Setup
89
- ```bash
90
- createdb authlib
91
- python -m authlib.cli db init
92
- ```
93
-
94
- ### Running Tests
95
- ```bash
96
- pytest
97
- ```
@@ -1,114 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: the37lab_authlib
3
- Version: 0.1.1750143654
4
- Summary: Python SDK for the Authlib
5
- Author-email: the37lab <info@the37lab.com>
6
- Classifier: Programming Language :: Python :: 3
7
- Classifier: Operating System :: OS Independent
8
- Requires-Python: >=3.9
9
- Description-Content-Type: text/markdown
10
- Requires-Dist: flask
11
- Requires-Dist: psycopg2-binary
12
- Requires-Dist: pyjwt
13
- Requires-Dist: python-dotenv
14
- Requires-Dist: requests
15
- Requires-Dist: authlib
16
- Requires-Dist: bcrypt
17
-
18
- # AuthLib
19
-
20
- A Python authentication library that provides JWT, OAuth2, and API token authentication with PostgreSQL backend.
21
-
22
- ## Table of Contents
23
- - [Installation](#installation)
24
- - [Quick Start](#quick-start)
25
- - [Configuration](#configuration)
26
- - [API Endpoints](#api-endpoints)
27
- - [Development](#development)
28
-
29
- ## Installation
30
-
31
- ```bash
32
- pip install -e .
33
- ```
34
-
35
- ## Quick Start
36
-
37
- ```python
38
- from flask import Flask
39
- from authlib import AuthManager
40
-
41
- app = Flask(__name__)
42
-
43
- auth = AuthManager(
44
- app=app,
45
- db_dsn="postgresql://user:pass@localhost/dbname",
46
- jwt_secret="your-secret-key",
47
- oauth_config={
48
- "google": {
49
- "client_id": "your-client-id",
50
- "client_secret": "your-client-secret"
51
- }
52
- }
53
- )
54
-
55
- @app.route("/protected")
56
- @auth.require_auth(roles=["admin"])
57
- def protected_route():
58
- return "Protected content"
59
- ```
60
-
61
- ## Configuration
62
-
63
- ### Required Parameters
64
- - `app`: Flask application instance
65
- - `db_dsn`: PostgreSQL connection string
66
- - `jwt_secret`: Secret key for JWT signing
67
-
68
- ### Optional Parameters
69
- - `oauth_config`: Dictionary of OAuth provider configurations
70
- - `token_expiry`: JWT token expiry time in seconds (default: 3600)
71
- - `refresh_token_expiry`: Refresh token expiry time in seconds (default: 2592000)
72
-
73
- ## API Endpoints
74
-
75
- ### Authentication
76
- - `POST /v1/users/login` - Login with username/password
77
- - `POST /v1/users/login/oauth` - Get OAuth redirect URL
78
- - `GET /v1/users/login/oauth2callback` - OAuth callback
79
- - `POST /v1/users/token-refresh` - Refresh JWT token
80
-
81
- ### User Management
82
- - `POST /v1/users/register` - Register new user
83
- - `GET /v1/users/login/profile` - Get user profile
84
- - `GET /v1/users/roles` - Get available roles
85
-
86
- ### API Tokens
87
- - `POST /v1/users/{user}/api-tokens` - Create API token
88
- - `GET /v1/users/{user}/api-tokens` - List API tokens
89
- - `DELETE /v1/users/{user}/api-tokens/{token_id}` - Delete API token
90
-
91
- ## Development
92
-
93
- ### Setup
94
- 1. Clone the repository
95
- 2. Create virtual environment:
96
- ```bash
97
- python -m venv venv
98
- venv\Scripts\activate
99
- ```
100
- 3. Install dependencies:
101
- ```bash
102
- pip install -e ".[dev]"
103
- ```
104
-
105
- ### Database Setup
106
- ```bash
107
- createdb authlib
108
- python -m authlib.cli db init
109
- ```
110
-
111
- ### Running Tests
112
- ```bash
113
- pytest
114
- ```