square-authentication 10.0.2__tar.gz → 10.0.4__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.
Files changed (49) hide show
  1. square_authentication-10.0.4/.github/workflows/docker-build-publish.yaml +61 -0
  2. square_authentication-10.0.4/.github/workflows/pypi-publish.yaml +34 -0
  3. square_authentication-10.0.4/.github/workflows/pytest.yaml +29 -0
  4. square_authentication-10.0.4/.gitignore +8 -0
  5. square_authentication-10.0.4/CHANGELOG.md +284 -0
  6. square_authentication-10.0.4/Dockerfile +12 -0
  7. {square_authentication-10.0.2 → square_authentication-10.0.4}/PKG-INFO +24 -31
  8. square_authentication-10.0.4/pyproject.toml +52 -0
  9. {square_authentication-10.0.2 → square_authentication-10.0.4}/square_authentication/configuration.py +13 -4
  10. {square_authentication-10.0.2 → square_authentication-10.0.4}/square_authentication/data/config.sample.ini +3 -0
  11. {square_authentication-10.0.2 → square_authentication-10.0.4}/square_authentication/data/config.testing.sample.ini +3 -0
  12. square_authentication-10.0.4/tests/conftest.py +89 -0
  13. square_authentication-10.0.2/pyproject.toml +0 -3
  14. square_authentication-10.0.2/setup.cfg +0 -4
  15. square_authentication-10.0.2/setup.py +0 -50
  16. square_authentication-10.0.2/square_authentication.egg-info/PKG-INFO +0 -74
  17. square_authentication-10.0.2/square_authentication.egg-info/SOURCES.txt +0 -39
  18. square_authentication-10.0.2/square_authentication.egg-info/dependency_links.txt +0 -1
  19. square_authentication-10.0.2/square_authentication.egg-info/requires.txt +0 -16
  20. square_authentication-10.0.2/square_authentication.egg-info/top_level.txt +0 -1
  21. {square_authentication-10.0.2 → square_authentication-10.0.4}/LICENSE +0 -0
  22. {square_authentication-10.0.2 → square_authentication-10.0.4}/README.md +0 -0
  23. {square_authentication-10.0.2 → square_authentication-10.0.4}/square_authentication/__init__.py +0 -0
  24. {square_authentication-10.0.2 → square_authentication-10.0.4}/square_authentication/main.py +0 -0
  25. {square_authentication-10.0.2 → square_authentication-10.0.4}/square_authentication/messages.py +0 -0
  26. {square_authentication-10.0.2 → square_authentication-10.0.4}/square_authentication/pydantic_models/__init__.py +0 -0
  27. {square_authentication-10.0.2 → square_authentication-10.0.4}/square_authentication/pydantic_models/core.py +0 -0
  28. {square_authentication-10.0.2 → square_authentication-10.0.4}/square_authentication/pydantic_models/profile.py +0 -0
  29. {square_authentication-10.0.2 → square_authentication-10.0.4}/square_authentication/routes/__init__.py +0 -0
  30. {square_authentication-10.0.2 → square_authentication-10.0.4}/square_authentication/routes/core.py +0 -0
  31. {square_authentication-10.0.2 → square_authentication-10.0.4}/square_authentication/routes/profile.py +0 -0
  32. {square_authentication-10.0.2 → square_authentication-10.0.4}/square_authentication/routes/utility.py +0 -0
  33. {square_authentication-10.0.2 → square_authentication-10.0.4}/square_authentication/utils/__init__.py +0 -0
  34. {square_authentication-10.0.2 → square_authentication-10.0.4}/square_authentication/utils/core.py +0 -0
  35. {square_authentication-10.0.2 → square_authentication-10.0.4}/square_authentication/utils/encryption.py +0 -0
  36. {square_authentication-10.0.2 → square_authentication-10.0.4}/square_authentication/utils/routes/__init__.py +0 -0
  37. {square_authentication-10.0.2 → square_authentication-10.0.4}/square_authentication/utils/routes/core.py +0 -0
  38. {square_authentication-10.0.2 → square_authentication-10.0.4}/square_authentication/utils/routes/profile.py +0 -0
  39. {square_authentication-10.0.2 → square_authentication-10.0.4}/square_authentication/utils/routes/utility.py +0 -0
  40. {square_authentication-10.0.2 → square_authentication-10.0.4}/square_authentication/utils/token.py +0 -0
  41. {square_authentication-10.0.2 → square_authentication-10.0.4}/tests/test_1.py +0 -0
  42. {square_authentication-10.0.2 → square_authentication-10.0.4}/tests/test_authentication.py +0 -0
  43. {square_authentication-10.0.2 → square_authentication-10.0.4}/tests/test_delete_user.py +0 -0
  44. {square_authentication-10.0.2 → square_authentication-10.0.4}/tests/test_email_verification.py +0 -0
  45. {square_authentication-10.0.2 → square_authentication-10.0.4}/tests/test_login.py +0 -0
  46. {square_authentication-10.0.2 → square_authentication-10.0.4}/tests/test_profile_management.py +0 -0
  47. {square_authentication-10.0.2 → square_authentication-10.0.4}/tests/test_token_management.py +0 -0
  48. {square_authentication-10.0.2 → square_authentication-10.0.4}/tests/test_update_profile.py +0 -0
  49. {square_authentication-10.0.2 → square_authentication-10.0.4}/tests/test_username.py +0 -0
@@ -0,0 +1,61 @@
1
+ name: Build and Deploy Docker Image
2
+
3
+ on:
4
+ release:
5
+ types: [ published ]
6
+ workflow_dispatch:
7
+ inputs:
8
+ release_tag:
9
+ description: "Release Tag"
10
+ required: true
11
+ is_latest:
12
+ description: "Tag as latest"
13
+ required: true
14
+ type: boolean
15
+
16
+ jobs:
17
+ build:
18
+ runs-on: ubuntu-latest
19
+
20
+ steps:
21
+ - name: Checkout code
22
+ uses: actions/checkout@v4
23
+
24
+ - name: Set Release Tag
25
+ id: set-tag
26
+ run: |
27
+ if [[ "${{ github.event_name }}" == "release" ]]; then
28
+ echo "Release triggered with tag: ${{ github.event.release.tag_name }}"
29
+ echo "RELEASE_TAG=${{ github.event.release.tag_name }}" >> $GITHUB_ENV
30
+ # Automatically tag as latest during a release event if needed
31
+ LATEST_TAG=$(curl -s https://api.github.com/repos/${{ github.repository }}/releases/latest | jq -r .tag_name)
32
+ if [[ "${{ github.event.release.tag_name }}" == "$LATEST_TAG" ]]; then
33
+ echo "IS_LATEST=true" >> $GITHUB_ENV
34
+ else
35
+ echo "IS_LATEST=false" >> $GITHUB_ENV
36
+ fi
37
+ else
38
+ echo "Manual trigger with user input tag: ${{ github.event.inputs.release_tag }}"
39
+ echo "RELEASE_TAG=${{ github.event.inputs.release_tag }}" >> $GITHUB_ENV
40
+ echo "IS_LATEST=${{ github.event.inputs.is_latest }}" >> $GITHUB_ENV
41
+ fi
42
+
43
+ - name: Set up Docker Buildx
44
+ uses: docker/setup-buildx-action@v3.3.0
45
+
46
+ - name: Set up QEMU
47
+ uses: docker/setup-qemu-action@v3
48
+
49
+ - name: Log in to Docker Hub
50
+ uses: docker/login-action@v3
51
+ with:
52
+ username: ${{ secrets.DOCKERHUB_USERNAME }}
53
+ password: ${{ secrets.DOCKERHUB_TOKEN }}
54
+
55
+ - name: Build and push multi-arch Docker image
56
+ run: |
57
+ docker buildx build \
58
+ --platform linux/amd64,linux/arm64 \
59
+ -t ${{ secrets.DOCKERHUB_USERNAME }}/$(basename ${{ github.repository }}):${{ env.RELEASE_TAG }} \
60
+ $([ "${{ env.IS_LATEST }}" == "true" ] && echo "-t ${{ secrets.DOCKERHUB_USERNAME }}/$(basename ${{ github.repository }}):latest") \
61
+ --push .
@@ -0,0 +1,34 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ release:
5
+ types:
6
+ - created
7
+ workflow_dispatch:
8
+
9
+ jobs:
10
+ build:
11
+ runs-on: ubuntu-latest
12
+
13
+ steps:
14
+ - name: Checkout code
15
+ uses: actions/checkout@v4
16
+
17
+ - name: Set up Python
18
+ uses: actions/setup-python@v5
19
+ with:
20
+ python-version: 3.12
21
+
22
+ - name: Install dependencies
23
+ run: |
24
+ python -m pip install --upgrade pip
25
+ python -m pip install build twine
26
+
27
+ - name: Build and publish
28
+ run: |
29
+ python -m build
30
+
31
+ - name: Publish package to PyPI
32
+ uses: pypa/gh-action-pypi-publish@release/v1
33
+ with:
34
+ password: ${{ secrets.PYPI_TOKEN }}
@@ -0,0 +1,29 @@
1
+ name: Run Tests
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ workflow_dispatch:
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+ env:
13
+ DB_PASSWORD: ${{ secrets.DB_PASSWORD }}
14
+ steps:
15
+ - name: Checkout code
16
+ uses: actions/checkout@v4
17
+
18
+ - name: Set up Python
19
+ uses: actions/setup-python@v5
20
+ with:
21
+ python-version: 3.12
22
+
23
+ - name: Install dependencies
24
+ run: |
25
+ python -m pip install --upgrade pip
26
+ pip install .
27
+
28
+ - name: Run tests
29
+ run: pytest
@@ -0,0 +1,8 @@
1
+ __pycache__/
2
+ .idea/
3
+ build/
4
+ *.egg-info/
5
+ logs
6
+ temp
7
+ config.ini
8
+ config.testing.ini
@@ -0,0 +1,284 @@
1
+ # changelog
2
+
3
+ ## v10.0.4
4
+
5
+ - remove setup.py and switch to pyproject.toml
6
+
7
+ ## v10.0.3
8
+
9
+ - env
10
+ - SQUARE_LOGGER -> FORMATTER_CHOICE + ENABLE_REDACTION
11
+ - dependencies
12
+ - square_logger>=3.0.0.
13
+
14
+ ## v10.0.2
15
+
16
+ - move application logic from route to utils.
17
+
18
+ ## v10.0.1
19
+
20
+ - core
21
+ - add username in get_user_details_v0 output.
22
+
23
+ ## v10.0.0
24
+
25
+ - core
26
+ - **breaking change**: logout_apps_v0 is now a POST method instead of DELETE.
27
+ - docs
28
+ - add GNU license v3.0.
29
+ - update README.md.
30
+ - move CHANGELOG to a separate file.
31
+ - tests
32
+ - fix bugs in test cases.
33
+ - dependencies
34
+ - square_database_structure >= 2.6.0.
35
+ - square_database_helper>=2.6.1.
36
+
37
+ ## v9.0.1
38
+
39
+ - env
40
+ - add RESEND_COOL_DOWN_TIME_FOR_EMAIL_VERIFICATION_CODE_IN_SECONDS and
41
+ RESEND_COOL_DOWN_TIME_FOR_EMAIL_PASSWORD_RESET_CODE_IN_SECONDS in LOGIC section.
42
+ - profile
43
+ - add validation for email verification code already sent in send_verification_email_v0.
44
+ - add cooldown_reset_at in send_verification_email_v0 output.
45
+ - core
46
+ - add validation for email password reset code already sent in send_reset_password_email_v0.
47
+ - add cooldown_reset_at in send_reset_password_email_v0 output.
48
+
49
+ ## v9.0.0
50
+
51
+ - core
52
+ - **breaking change**: new mandatory parameter `app_id` in validate_and_get_payload_from_token_v0.
53
+
54
+ ## v8.0.2
55
+
56
+ - core
57
+ - add refresh_token_expiry_time in output for reset_password_and_login_using_backup_code_v0 and
58
+ reset_password_and_login_using_reset_email_code_v0.
59
+
60
+ ## v8.0.1
61
+
62
+ - core
63
+ - add make recovery_methods_to_add and recovery_methods_to_remove parameters optional in
64
+ update_user_recovery_methods_v0.
65
+
66
+ ## v8.0.0
67
+
68
+ - env
69
+ - add GOOGLE section and GOOGLE_AUTH_PLATFORM_CLIENT_ID variable.
70
+ - add LOGIC section with NUMBER_OF_RECOVERY_CODES, EXPIRY_TIME_FOR_EMAIL_VERIFICATION_CODE_IN_SECONDS,
71
+ NUMBER_OF_DIGITS_IN_EMAIL_VERIFICATION_CODE, EXPIRY_TIME_FOR_EMAIL_PASSWORD_RESET_CODE_IN_SECONDS,
72
+ NUMBER_OF_DIGITS_IN_EMAIL_PASSWORD_RESET_CODE variables.
73
+ - dependencies
74
+ - add google-auth>=2.40.3.
75
+ - update square_commons to >=3.0.0.
76
+ - core
77
+ - add reset_password_and_login_using_reset_email_code_v0.
78
+ - **breaking change**: remove app_id from send_reset_password_email_v0.
79
+ - implement deletion of existing backup codes before generating new ones (generate_account_backup_codes_v0).
80
+ - implement deletion of existing backup codes before removing recovery method (update_user_recovery_methods_v0).
81
+ - implement logout_other_sessions in update_password_v0, reset_password_and_login_using_backup_code_v0 and
82
+ reset_password_and_login_using_reset_email_code_v0
83
+ - in update_password_v0, it will log out all other sessions except the current one if valid (optional)
84
+ refresh_token is passed in.
85
+ - add register_login_google_v0, **finally**.
86
+ - add validation in update_password_v0, reset_password_and_login_using_backup_code_v0, send_reset_password_email_v0,
87
+ reset_password_and_login_using_reset_email_code_v0 to check if user has credentials and has self as auth provider.
88
+ - remove profile_photo from file_store when user is deleted in delete_user_v0.
89
+ - utils
90
+ - add new core file with generate_default_username_for_google_users function.
91
+ - tests
92
+ - add test_login_fail_v0.
93
+
94
+ ## v7.0.0
95
+
96
+ - internal support for UserAuthProvider.
97
+ - internal support for username shifted from UserProfile to User.
98
+ - internal support for phone number country code in UserProfile.
99
+ - core
100
+ - register_username_v0 fixed to account for changes mentioned above and creates empty profile.
101
+ - login_username_v0 fixed to account for changes mentioned above.
102
+ - update_username_v0 fixed to account for changes mentioned above.
103
+ - **breaking change**: delete_user_v0 is now a POST method instead of DELETE.
104
+ - add generate_account_backup_codes_v0.
105
+ - add reset_password_and_login_using_backup_code_v0.
106
+ - add validation for email verification when adding email as recovery method in update_user_recovery_methods_v0.
107
+ - add send_reset_password_email_v0.
108
+ - profile
109
+ - add update_profile_details_v0.
110
+ - add send_verification_email_v0.
111
+ - add validate_email_verification_code_v0.
112
+ - tests
113
+ - add test cases and fixtures for login_username_v0.
114
+ - add test cases and fixtures for delete_user_v0.
115
+ - add test cases and fixtures for update_profile_details_v0.
116
+ - env
117
+ - add EMAIL section and MAIL_GUN_API_KEY variable.
118
+
119
+ ## v6.2.2
120
+
121
+ - remove config.ini and config.testing.ini from version control.
122
+
123
+ ## v6.2.1
124
+
125
+ - core
126
+ - tweak validation for username in register_username_v0 and update_username_v0.
127
+
128
+ ## v6.2.0
129
+
130
+ - core
131
+ - add update_user_recovery_methods_v0.
132
+
133
+ ## v6.1.0
134
+
135
+ - add validation to username in register_username_v0 and update_username_v0.
136
+ - add test cases for register_username_v0.
137
+
138
+ ## v6.0.5
139
+
140
+ - env
141
+ - add ALLOW_ORIGINS
142
+
143
+ ## v6.0.4
144
+
145
+ - mock ini file for pytest.
146
+
147
+ ## v6.0.3
148
+
149
+ - make profile photo upload optional in update_profile_photo/v0, to enable users to remove their profile photo.
150
+
151
+ ## v6.0.2
152
+
153
+ - bump square_file_store_helper to >=3.0.0.
154
+ - use upload_file_using_tuple_v0 instead of upload_file_using_path_v0 in update_profile_photo/v0.
155
+
156
+ ## v6.0.1
157
+
158
+ - delete previous profile photo from file store after successfully updating profile photo.
159
+
160
+ ## v6.0.0
161
+
162
+ - add profile details in get_user_details_v0 instead of credentials keyword.
163
+
164
+ ## v5.2.0
165
+
166
+ - add temp folder to .gitignore.
167
+ - add square_file_store_helper as a dependency.
168
+ - config
169
+ - add config section for file store helper.
170
+ - initialise file store helper and database helper in config.py
171
+ - add profile router
172
+ - profile
173
+ - add update_profile_photo/v0
174
+ - update messages.
175
+
176
+ ## v5.1.5
177
+
178
+ - bump square_logger to >=2.0.0.
179
+
180
+ ## v5.1.4
181
+
182
+ - re bug fix v5.1.3
183
+
184
+ ## v5.1.3
185
+
186
+ - bugfix in login_username/v0 (getting creds from correct table).
187
+
188
+ ## v5.1.2
189
+
190
+ - bump square_database_structure>=2.3.1.
191
+ - change logic to read username from profile instead of credentials table.
192
+
193
+ ## v5.1.1
194
+
195
+ - add logger decorator in all functions.
196
+ - add error logs in all endpoints.
197
+
198
+ ## v5.1.0
199
+
200
+ - Core
201
+ - add logout/apps/v0.
202
+ - add logout/all/v0.
203
+
204
+ ## v5.0.1
205
+
206
+ - fix typo in return value of get_user_details_v0.
207
+
208
+ ## v5.0.0
209
+
210
+ - change get_user_details_v0 to return app name instead of app ids.
211
+
212
+ ## v4.5.1
213
+
214
+ - fix auto docker image build github action.
215
+
216
+ ## v4.5.0
217
+
218
+ - add pytest dependency and dummy test.
219
+ - add https dependency.
220
+ - github actions for CI/CD for testing and auto build and push.
221
+
222
+ ## v4.4.0
223
+
224
+ - core
225
+ - add refresh_token_expiry_time in register_username_v0, login_username_v0.
226
+
227
+ ## v4.3.0
228
+
229
+ - set allow_credentials=True.
230
+
231
+ ## v4.2.1
232
+
233
+ - fix output format in validate_and_get_payload_from_token/v0.
234
+ - add db check refresh token validation in validate_and_get_payload_from_token/v0.
235
+
236
+ ## v4.2.0
237
+
238
+ - add validate_and_get_payload_from_token/v0 in core.
239
+
240
+ ## v4.1.0
241
+
242
+ - add get_text_hash/v0 in utils.
243
+
244
+ ## v4.0.1
245
+
246
+ - bugfix in pydantic model import.
247
+
248
+ ## v4.0.0
249
+
250
+ - /login_username/v0 is now POST method.
251
+ - new flag in /login_username/v0 assign_app_id_if_missing.
252
+ - bugfix: /get_user_details/v0 now only returns number of active sessions.
253
+
254
+ ## v3.0.0
255
+
256
+ - added new endpoints
257
+ - /update_username/v0
258
+ - /delete_user/v0
259
+ - /update_password/v0
260
+ - move data in password related endpoints to request body from params.
261
+ - /register_username/v0 now takes in app_id as optional parameter to assign user to that app and create session for it.
262
+ - /generate_access_token/v0 now only needs refresh token (removed validation).
263
+ - /logout/v0 now only needs refresh token (removed validation).
264
+ - /update_user_app_ids/v0 now only updates ids for self (user). added access token as input param and removed user_id.
265
+ - /get_user_app_ids/v0 is now /get_user_details/v0 with access token as the only input param.
266
+
267
+ ## v2.0.0
268
+
269
+ - authentication module needs to be used across applications so
270
+ - register_username: will not create sessions and therefore will not auto login.
271
+ - login: added validation if app is assigned to user before assigning it and added app_id in session row.
272
+ - logout: added app_id as new parameter and validation for that.
273
+ - generate_access_token: added app_id as new parameter and validation for that.
274
+ - added 2 new endpoints
275
+ - get user app ids: **access token validation pending**.
276
+ - change user app ids: **access token validation pending**.
277
+ - add versions for all endpoint paths.
278
+ - make it compatible with square_database_helper 2.x.
279
+ - username in database will always be lowercase.
280
+ - standardise output formats for all api.
281
+
282
+ ## v1.0.0
283
+
284
+ - initial implementation.
@@ -0,0 +1,12 @@
1
+ FROM python:3.12-slim
2
+
3
+ COPY . /app
4
+
5
+ WORKDIR /app
6
+
7
+ RUN pip install .
8
+
9
+ CMD ["python3", "/usr/local/lib/python3.12/site-packages/square_authentication/main.py"]
10
+
11
+ # Uncomment for debugging
12
+ # CMD ["bash", "-c", "while true; do sleep 60; done"]
@@ -1,48 +1,41 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: square_authentication
3
- Version: 10.0.2
3
+ Version: 10.0.4
4
4
  Summary: authentication layer for my personal server.
5
- Home-page: https://github.com/thepmsquare/square_authentication
6
- Author: Parth Mukesh Mangtani
7
- Author-email: thepmsquare@gmail.com
5
+ Project-URL: homepage, https://github.com/thepmsquare/square_authentication
6
+ Author-email: Parth Mukesh Mangtani <thepmsquare@gmail.com>
7
+ License: GPLv3
8
+ License-File: LICENSE
9
+ Keywords: authentication,fastapi,server,utilities
8
10
  Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Framework :: FastAPI
9
12
  Classifier: Intended Audience :: Developers
10
13
  Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
11
14
  Classifier: Operating System :: OS Independent
12
15
  Classifier: Programming Language :: Python :: 3
13
- Classifier: Programming Language :: Python :: 3.12
14
16
  Classifier: Programming Language :: Python :: 3 :: Only
15
- Classifier: Topic :: Security
16
- Classifier: Topic :: Internet :: WWW/HTTP :: HTTP Servers
17
+ Classifier: Programming Language :: Python :: 3.12
17
18
  Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
18
- Classifier: Framework :: FastAPI
19
- Description-Content-Type: text/markdown
20
- License-File: LICENSE
21
- Requires-Dist: uvicorn>=0.24.0.post1
19
+ Classifier: Topic :: Internet :: WWW/HTTP :: HTTP Servers
20
+ Classifier: Topic :: Security
21
+ Requires-Python: >=3.12
22
+ Requires-Dist: bcrypt>=4.1.2
23
+ Requires-Dist: cryptography>=42.0.7
22
24
  Requires-Dist: fastapi>=0.104.1
23
- Requires-Dist: python-multipart>=0.0.6
25
+ Requires-Dist: google-auth>=2.40.3
26
+ Requires-Dist: httpx>=0.27.2
24
27
  Requires-Dist: pydantic>=2.5.3
25
- Requires-Dist: bcrypt>=4.1.2
26
28
  Requires-Dist: pyjwt>=2.8.0
27
- Requires-Dist: requests>=2.32.3
28
- Requires-Dist: cryptography>=42.0.7
29
- Requires-Dist: square_commons>=3.0.0
30
- Requires-Dist: square_logger>=2.0.0
31
- Requires-Dist: square_database_helper>=2.6.1
32
- Requires-Dist: square_database_structure>=2.6.0
33
- Requires-Dist: square_file_store_helper>=3.0.0
34
29
  Requires-Dist: pytest>=8.0.0
35
- Requires-Dist: httpx>=0.27.2
36
- Requires-Dist: google-auth>=2.40.3
37
- Dynamic: author
38
- Dynamic: author-email
39
- Dynamic: classifier
40
- Dynamic: description
41
- Dynamic: description-content-type
42
- Dynamic: home-page
43
- Dynamic: license-file
44
- Dynamic: requires-dist
45
- Dynamic: summary
30
+ Requires-Dist: python-multipart>=0.0.6
31
+ Requires-Dist: requests>=2.32.3
32
+ Requires-Dist: square-commons>=3.0.0
33
+ Requires-Dist: square-database-helper>=2.6.1
34
+ Requires-Dist: square-database-structure>=2.6.0
35
+ Requires-Dist: square-file-store-helper>=3.0.0
36
+ Requires-Dist: square-logger>=3.0.0
37
+ Requires-Dist: uvicorn>=0.24.0.post1
38
+ Description-Content-Type: text/markdown
46
39
 
47
40
  # square_authentication
48
41
 
@@ -0,0 +1,52 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "square_authentication"
7
+ version = "10.0.4"
8
+ description = "authentication layer for my personal server."
9
+ readme = "README.md"
10
+ readme-content-type = "text/markdown"
11
+ requires-python = ">=3.12"
12
+ license = { text = "GPLv3" }
13
+ authors = [
14
+ { name = "Parth Mukesh Mangtani", email = "thepmsquare@gmail.com" },
15
+ ]
16
+ urls = { homepage = "https://github.com/thepmsquare/square_authentication" }
17
+ keywords = ["authentication", "fastapi", "server", "utilities"]
18
+ dependencies = [
19
+ "uvicorn>=0.24.0.post1",
20
+ "fastapi>=0.104.1",
21
+ "python-multipart>=0.0.6",
22
+ "pydantic>=2.5.3",
23
+ "bcrypt>=4.1.2",
24
+ "pyjwt>=2.8.0",
25
+ "requests>=2.32.3",
26
+ "cryptography>=42.0.7",
27
+ "square_commons>=3.0.0",
28
+ "square_logger>=3.0.0",
29
+ "square_database_helper>=2.6.1",
30
+ "square_database_structure>=2.6.0",
31
+ "square_file_store_helper>=3.0.0",
32
+ "pytest>=8.0.0",
33
+ "httpx>=0.27.2",
34
+ "google-auth>=2.40.3",
35
+ ]
36
+ classifiers = [
37
+ "Development Status :: 3 - Alpha",
38
+ "Intended Audience :: Developers",
39
+ "License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
40
+ "Operating System :: OS Independent",
41
+ "Programming Language :: Python :: 3",
42
+ "Programming Language :: Python :: 3.12",
43
+ "Programming Language :: Python :: 3 :: Only",
44
+ "Topic :: Security",
45
+ "Topic :: Internet :: WWW/HTTP :: HTTP Servers",
46
+ "Topic :: Internet :: WWW/HTTP :: Dynamic Content",
47
+ "Framework :: FastAPI"
48
+ ]
49
+
50
+ [tool.hatch.build.targets.wheel]
51
+ packages = ["square_authentication"]
52
+ include = ["square_authentication/data/*"]
@@ -65,6 +65,12 @@ try:
65
65
  config_int_log_backup_count = int(
66
66
  ldict_configuration["SQUARE_LOGGER"]["LOG_BACKUP_COUNT"]
67
67
  )
68
+ config_formatter_choice = ldict_configuration["SQUARE_LOGGER"]["FORMATTER_CHOICE"]
69
+ if config_formatter_choice not in ("human_readable", "json"):
70
+ raise ValueError(f"Invalid formatter choice: {config_formatter_choice}")
71
+ config_bool_enable_redaction = eval(
72
+ ldict_configuration["SQUARE_LOGGER"]["ENABLE_REDACTION"]
73
+ )
68
74
  # ===========================================
69
75
 
70
76
  # ===========================================
@@ -93,6 +99,7 @@ try:
93
99
  config_int_square_file_store_port = int(
94
100
  ldict_configuration["SQUARE_FILE_STORE_HELPER"]["SQUARE_FILE_STORE_PORT"]
95
101
  )
102
+
96
103
  # ===========================================
97
104
 
98
105
  # ===========================================
@@ -143,10 +150,12 @@ try:
143
150
 
144
151
  # Initialize logger
145
152
  global_object_square_logger = SquareLogger(
146
- pstr_log_file_name=config_str_log_file_name,
147
- pint_log_level=config_int_log_level,
148
- pstr_log_path=config_str_log_path,
149
- pint_log_backup_count=config_int_log_backup_count,
153
+ log_file_name=config_str_log_file_name,
154
+ log_level=config_int_log_level,
155
+ log_path=config_str_log_path,
156
+ log_backup_count=config_int_log_backup_count,
157
+ formatter_choice=config_formatter_choice,
158
+ enable_redaction=config_bool_enable_redaction,
150
159
  )
151
160
  global_object_square_database_helper = SquareDatabaseHelper(
152
161
  param_str_square_database_ip=config_str_square_database_ip,
@@ -40,6 +40,9 @@ LOG_PATH = logs
40
40
  # number of backup log files to keep during rotation
41
41
  # if backupCount is zero, rollover never occurs.
42
42
  LOG_BACKUP_COUNT = 3
43
+ # json or human_readable
44
+ FORMATTER_CHOICE = json
45
+ ENABLE_REDACTION = True
43
46
 
44
47
  [SQUARE_DATABASE_HELPER]
45
48
 
@@ -40,6 +40,9 @@ LOG_PATH = logs
40
40
  # number of backup log files to keep during rotation
41
41
  # if backupCount is zero, rollover never occurs.
42
42
  LOG_BACKUP_COUNT = 3
43
+ # json or human_readable
44
+ FORMATTER_CHOICE = json
45
+ ENABLE_REDACTION = True
43
46
 
44
47
  [SQUARE_DATABASE_HELPER]
45
48
 
@@ -0,0 +1,89 @@
1
+ import importlib
2
+ import os
3
+ import random
4
+
5
+ import pytest
6
+ from fastapi.testclient import TestClient
7
+
8
+
9
+ @pytest.fixture(scope="session")
10
+ def get_patched_configuration():
11
+ def patched_join(*args):
12
+ *rest, last = args
13
+ if last == "config.ini":
14
+ last = "config.testing.ini"
15
+ elif last == "config.sample.ini":
16
+ last = "config.testing.sample.ini"
17
+
18
+ return original_join(*rest, last)
19
+
20
+ original_join = os.path.join
21
+ os.path.join = patched_join
22
+
23
+ import square_authentication.configuration
24
+
25
+ importlib.reload(square_authentication.configuration)
26
+ config = square_authentication.configuration
27
+
28
+ yield config
29
+
30
+ # cleanup
31
+ os.path.join = original_join
32
+
33
+
34
+ @pytest.fixture(scope="session")
35
+ def create_client_and_cleanup(get_patched_configuration):
36
+ from square_database_structure import create_database_and_tables
37
+
38
+ create_database_and_tables(
39
+ db_username=get_patched_configuration.config_str_db_username,
40
+ db_port=get_patched_configuration.config_int_db_port,
41
+ db_password=get_patched_configuration.config_str_db_password,
42
+ db_ip=get_patched_configuration.config_str_db_ip,
43
+ drop_if_exists=True,
44
+ )
45
+ from square_authentication.main import (
46
+ app,
47
+ )
48
+
49
+ client = TestClient(app)
50
+ yield client
51
+ from sqlalchemy import text, create_engine
52
+ from square_database_structure.main import global_list_create
53
+
54
+ local_str_postgres_url = (
55
+ f"postgresql://{get_patched_configuration.config_str_db_username}:{get_patched_configuration.config_str_db_password}@"
56
+ f"{get_patched_configuration.config_str_db_ip}:{str(get_patched_configuration.config_int_db_port)}/"
57
+ )
58
+
59
+ postgres_engine = create_engine(local_str_postgres_url)
60
+
61
+ with postgres_engine.connect() as postgres_connection:
62
+
63
+ postgres_connection.execute(text("commit"))
64
+
65
+ for database in global_list_create:
66
+
67
+ postgres_connection.execute(
68
+ text(f"DROP DATABASE {database['database']} WITH (FORCE)")
69
+ )
70
+
71
+
72
+ @pytest.fixture()
73
+ def fixture_create_user(create_client_and_cleanup):
74
+ payload = {
75
+ "username": "testuser" + str(random.randint(1, 1000)),
76
+ "password": "testpass123",
77
+ "app_id": 1,
78
+ }
79
+ response = create_client_and_cleanup.post("/register_username/v0", json=payload)
80
+ assert response.status_code == 201
81
+ yield payload, response.json()
82
+ # cleanup
83
+ cleanup_headers = {"access-token": response.json()["data"]["main"]["access_token"]}
84
+ cleanup_payload = {
85
+ "password": payload["password"],
86
+ }
87
+ create_client_and_cleanup.post(
88
+ "/delete_user/v0", json=cleanup_payload, headers=cleanup_headers
89
+ )
@@ -1,3 +0,0 @@
1
- [build-system]
2
- requires = ["setuptools>=75.3.0", "wheel"]
3
- build-backend = "setuptools.build_meta"
@@ -1,4 +0,0 @@
1
- [egg_info]
2
- tag_build =
3
- tag_date = 0
4
-
@@ -1,50 +0,0 @@
1
- from setuptools import find_packages, setup
2
-
3
- package_name = "square_authentication"
4
-
5
- setup(
6
- name=package_name,
7
- version="10.0.2",
8
- packages=find_packages(),
9
- package_data={
10
- package_name: ["data/*"],
11
- },
12
- install_requires=[
13
- "uvicorn>=0.24.0.post1",
14
- "fastapi>=0.104.1",
15
- "python-multipart>=0.0.6",
16
- "pydantic>=2.5.3",
17
- "bcrypt>=4.1.2",
18
- "pyjwt>=2.8.0",
19
- "requests>=2.32.3",
20
- "cryptography>=42.0.7",
21
- "square_commons>=3.0.0",
22
- "square_logger>=2.0.0",
23
- "square_database_helper>=2.6.1",
24
- "square_database_structure>=2.6.0",
25
- "square_file_store_helper>=3.0.0",
26
- "pytest>=8.0.0",
27
- "httpx>=0.27.2",
28
- "google-auth>=2.40.3",
29
- ],
30
- extras_require={},
31
- author="Parth Mukesh Mangtani",
32
- author_email="thepmsquare@gmail.com",
33
- description="authentication layer for my personal server.",
34
- long_description=open("README.md", "r", encoding="utf-8").read(),
35
- long_description_content_type="text/markdown",
36
- url=f"https://github.com/thepmsquare/{package_name}",
37
- classifiers=[
38
- "Development Status :: 3 - Alpha",
39
- "Intended Audience :: Developers",
40
- "License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
41
- "Operating System :: OS Independent",
42
- "Programming Language :: Python :: 3",
43
- "Programming Language :: Python :: 3.12",
44
- "Programming Language :: Python :: 3 :: Only",
45
- "Topic :: Security",
46
- "Topic :: Internet :: WWW/HTTP :: HTTP Servers",
47
- "Topic :: Internet :: WWW/HTTP :: Dynamic Content",
48
- "Framework :: FastAPI",
49
- ],
50
- )
@@ -1,74 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: square_authentication
3
- Version: 10.0.2
4
- Summary: authentication layer for my personal server.
5
- Home-page: https://github.com/thepmsquare/square_authentication
6
- Author: Parth Mukesh Mangtani
7
- Author-email: thepmsquare@gmail.com
8
- Classifier: Development Status :: 3 - Alpha
9
- Classifier: Intended Audience :: Developers
10
- Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
11
- Classifier: Operating System :: OS Independent
12
- Classifier: Programming Language :: Python :: 3
13
- Classifier: Programming Language :: Python :: 3.12
14
- Classifier: Programming Language :: Python :: 3 :: Only
15
- Classifier: Topic :: Security
16
- Classifier: Topic :: Internet :: WWW/HTTP :: HTTP Servers
17
- Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
18
- Classifier: Framework :: FastAPI
19
- Description-Content-Type: text/markdown
20
- License-File: LICENSE
21
- Requires-Dist: uvicorn>=0.24.0.post1
22
- Requires-Dist: fastapi>=0.104.1
23
- Requires-Dist: python-multipart>=0.0.6
24
- Requires-Dist: pydantic>=2.5.3
25
- Requires-Dist: bcrypt>=4.1.2
26
- Requires-Dist: pyjwt>=2.8.0
27
- Requires-Dist: requests>=2.32.3
28
- Requires-Dist: cryptography>=42.0.7
29
- Requires-Dist: square_commons>=3.0.0
30
- Requires-Dist: square_logger>=2.0.0
31
- Requires-Dist: square_database_helper>=2.6.1
32
- Requires-Dist: square_database_structure>=2.6.0
33
- Requires-Dist: square_file_store_helper>=3.0.0
34
- Requires-Dist: pytest>=8.0.0
35
- Requires-Dist: httpx>=0.27.2
36
- Requires-Dist: google-auth>=2.40.3
37
- Dynamic: author
38
- Dynamic: author-email
39
- Dynamic: classifier
40
- Dynamic: description
41
- Dynamic: description-content-type
42
- Dynamic: home-page
43
- Dynamic: license-file
44
- Dynamic: requires-dist
45
- Dynamic: summary
46
-
47
- # square_authentication
48
-
49
- > 📌 versioning: see [CHANGELOG.md](./CHANGELOG.md).
50
-
51
- ## about
52
-
53
- authentication layer for my personal server.
54
-
55
- ## goals
56
-
57
- - integration with square_*
58
- - unified authentication api across all projects
59
- - jwt token support
60
- - simple user and user profile management
61
- - oauth support
62
- - future extensibility
63
-
64
- ## Installation
65
-
66
- ```shell
67
- pip install square_authentication
68
- ```
69
-
70
- ## env
71
-
72
- - python>=3.12.0
73
-
74
- > feedback is appreciated. thank you!
@@ -1,39 +0,0 @@
1
- LICENSE
2
- README.md
3
- pyproject.toml
4
- setup.py
5
- square_authentication/__init__.py
6
- square_authentication/configuration.py
7
- square_authentication/main.py
8
- square_authentication/messages.py
9
- square_authentication.egg-info/PKG-INFO
10
- square_authentication.egg-info/SOURCES.txt
11
- square_authentication.egg-info/dependency_links.txt
12
- square_authentication.egg-info/requires.txt
13
- square_authentication.egg-info/top_level.txt
14
- square_authentication/data/config.sample.ini
15
- square_authentication/data/config.testing.sample.ini
16
- square_authentication/pydantic_models/__init__.py
17
- square_authentication/pydantic_models/core.py
18
- square_authentication/pydantic_models/profile.py
19
- square_authentication/routes/__init__.py
20
- square_authentication/routes/core.py
21
- square_authentication/routes/profile.py
22
- square_authentication/routes/utility.py
23
- square_authentication/utils/__init__.py
24
- square_authentication/utils/core.py
25
- square_authentication/utils/encryption.py
26
- square_authentication/utils/token.py
27
- square_authentication/utils/routes/__init__.py
28
- square_authentication/utils/routes/core.py
29
- square_authentication/utils/routes/profile.py
30
- square_authentication/utils/routes/utility.py
31
- tests/test_1.py
32
- tests/test_authentication.py
33
- tests/test_delete_user.py
34
- tests/test_email_verification.py
35
- tests/test_login.py
36
- tests/test_profile_management.py
37
- tests/test_token_management.py
38
- tests/test_update_profile.py
39
- tests/test_username.py
@@ -1,16 +0,0 @@
1
- uvicorn>=0.24.0.post1
2
- fastapi>=0.104.1
3
- python-multipart>=0.0.6
4
- pydantic>=2.5.3
5
- bcrypt>=4.1.2
6
- pyjwt>=2.8.0
7
- requests>=2.32.3
8
- cryptography>=42.0.7
9
- square_commons>=3.0.0
10
- square_logger>=2.0.0
11
- square_database_helper>=2.6.1
12
- square_database_structure>=2.6.0
13
- square_file_store_helper>=3.0.0
14
- pytest>=8.0.0
15
- httpx>=0.27.2
16
- google-auth>=2.40.3
@@ -1 +0,0 @@
1
- square_authentication