square-administration 2.1.0__tar.gz → 2.2.1__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.
- {square_administration-2.1.0 → square_administration-2.2.1}/PKG-INFO +11 -1
- {square_administration-2.1.0 → square_administration-2.2.1}/README.md +10 -0
- {square_administration-2.1.0 → square_administration-2.2.1}/setup.py +1 -1
- {square_administration-2.1.0 → square_administration-2.2.1}/square_administration/messages.py +1 -0
- {square_administration-2.1.0 → square_administration-2.2.1}/square_administration/routes/authentication.py +57 -7
- {square_administration-2.1.0 → square_administration-2.2.1}/square_administration.egg-info/PKG-INFO +11 -1
- {square_administration-2.1.0 → square_administration-2.2.1}/setup.cfg +0 -0
- {square_administration-2.1.0 → square_administration-2.2.1}/square_administration/__init__.py +0 -0
- {square_administration-2.1.0 → square_administration-2.2.1}/square_administration/configuration.py +0 -0
- {square_administration-2.1.0 → square_administration-2.2.1}/square_administration/data/config.ini +0 -0
- {square_administration-2.1.0 → square_administration-2.2.1}/square_administration/main.py +0 -0
- {square_administration-2.1.0 → square_administration-2.2.1}/square_administration/pydantic_models/__init__.py +0 -0
- {square_administration-2.1.0 → square_administration-2.2.1}/square_administration/pydantic_models/authentication.py +0 -0
- {square_administration-2.1.0 → square_administration-2.2.1}/square_administration/pydantic_models/core.py +0 -0
- {square_administration-2.1.0 → square_administration-2.2.1}/square_administration/routes/__init__.py +0 -0
- {square_administration-2.1.0 → square_administration-2.2.1}/square_administration/routes/core.py +0 -0
- {square_administration-2.1.0 → square_administration-2.2.1}/square_administration/utils/__init__.py +0 -0
- {square_administration-2.1.0 → square_administration-2.2.1}/square_administration.egg-info/SOURCES.txt +0 -0
- {square_administration-2.1.0 → square_administration-2.2.1}/square_administration.egg-info/dependency_links.txt +0 -0
- {square_administration-2.1.0 → square_administration-2.2.1}/square_administration.egg-info/requires.txt +0 -0
- {square_administration-2.1.0 → square_administration-2.2.1}/square_administration.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: square_administration
|
3
|
-
Version: 2.1
|
3
|
+
Version: 2.2.1
|
4
4
|
Summary: common business layer for my personal server.
|
5
5
|
Home-page: https://github.com/thepmsquare/square_administration
|
6
6
|
Author: thePmSquare
|
@@ -32,6 +32,16 @@ pip install square_administration
|
|
32
32
|
|
33
33
|
## changelog
|
34
34
|
|
35
|
+
### v2.2.1
|
36
|
+
|
37
|
+
- authentication
|
38
|
+
- add validation for refresh token app id in logout_v0, generate_access_token_v0.
|
39
|
+
|
40
|
+
### v2.2.0
|
41
|
+
|
42
|
+
- authentication
|
43
|
+
- logout_v0, generate_access_token_v0 remove refresh token from request header and accept in cookie.
|
44
|
+
|
35
45
|
### v2.1.0
|
36
46
|
|
37
47
|
- add authentication -> logout_v0, generate_access_token_v0.
|
@@ -16,6 +16,16 @@ pip install square_administration
|
|
16
16
|
|
17
17
|
## changelog
|
18
18
|
|
19
|
+
### v2.2.1
|
20
|
+
|
21
|
+
- authentication
|
22
|
+
- add validation for refresh token app id in logout_v0, generate_access_token_v0.
|
23
|
+
|
24
|
+
### v2.2.0
|
25
|
+
|
26
|
+
- authentication
|
27
|
+
- logout_v0, generate_access_token_v0 remove refresh token from request header and accept in cookie.
|
28
|
+
|
19
29
|
### v2.1.0
|
20
30
|
|
21
31
|
- add authentication -> logout_v0, generate_access_token_v0.
|
{square_administration-2.1.0 → square_administration-2.2.1}/square_administration/messages.py
RENAMED
@@ -12,4 +12,5 @@ messages = {
|
|
12
12
|
"GENERIC_500": "an internal server error occurred. please try again later.",
|
13
13
|
"INCORRECT_ACCESS_TOKEN": "the access token provided is invalid or expired.",
|
14
14
|
"INCORRECT_REFRESH_TOKEN": "the refresh token provided is invalid or expired.",
|
15
|
+
"REFRESH_TOKEN_NOT_FOUND": "refresh token not found. please login again.",
|
15
16
|
}
|
@@ -2,9 +2,10 @@ import json
|
|
2
2
|
from typing import Annotated
|
3
3
|
|
4
4
|
import bcrypt
|
5
|
-
from fastapi import APIRouter, status, HTTPException, Header
|
5
|
+
from fastapi import APIRouter, status, HTTPException, Header, Request
|
6
6
|
from fastapi.responses import JSONResponse
|
7
7
|
from requests import HTTPError
|
8
|
+
from square_authentication_helper import TokenType
|
8
9
|
from square_commons import get_api_output_in_standard_format
|
9
10
|
from square_commons.api_utils import create_cookie
|
10
11
|
|
@@ -260,15 +261,39 @@ async def remove_app_for_self_v0(
|
|
260
261
|
|
261
262
|
@router.delete("/logout/v0")
|
262
263
|
@global_object_square_logger.async_auto_logger
|
263
|
-
async def logout_v0(
|
264
|
-
refresh_token: Annotated[str, Header()],
|
265
|
-
):
|
264
|
+
async def logout_v0(request: Request):
|
266
265
|
|
267
266
|
try:
|
268
267
|
"""
|
269
268
|
validation
|
270
269
|
"""
|
271
|
-
|
270
|
+
|
271
|
+
refresh_token = request.cookies.get("refresh_token|" + str(global_int_app_id))
|
272
|
+
if refresh_token is None:
|
273
|
+
output_content = get_api_output_in_standard_format(
|
274
|
+
message=messages["REFRESH_TOKEN_NOT_FOUND"],
|
275
|
+
log=f"refresh token not found.",
|
276
|
+
)
|
277
|
+
return JSONResponse(
|
278
|
+
status_code=status.HTTP_400_BAD_REQUEST,
|
279
|
+
content=output_content,
|
280
|
+
)
|
281
|
+
refresh_token_payload = global_object_square_authentication_helper.validate_and_get_payload_from_token_v0(
|
282
|
+
refresh_token, TokenType.refresh_token
|
283
|
+
)[
|
284
|
+
"data"
|
285
|
+
][
|
286
|
+
"main"
|
287
|
+
]
|
288
|
+
if refresh_token_payload["app_id"] != global_int_app_id:
|
289
|
+
output_content = get_api_output_in_standard_format(
|
290
|
+
message=messages["INCORRECT_REFRESH_TOKEN"],
|
291
|
+
log=f"refresh token is for different app id. intended app id: {global_int_app_id}, actual app id: {refresh_token_payload['app_id']}.",
|
292
|
+
)
|
293
|
+
return JSONResponse(
|
294
|
+
status_code=status.HTTP_400_BAD_REQUEST,
|
295
|
+
content=output_content,
|
296
|
+
)
|
272
297
|
"""
|
273
298
|
main process
|
274
299
|
"""
|
@@ -320,14 +345,39 @@ async def logout_v0(
|
|
320
345
|
@router.get("/generate_access_token/v0")
|
321
346
|
@global_object_square_logger.async_auto_logger
|
322
347
|
async def generate_access_token_v0(
|
323
|
-
|
348
|
+
request: Request,
|
324
349
|
):
|
325
350
|
|
326
351
|
try:
|
327
352
|
"""
|
328
353
|
validation
|
329
354
|
"""
|
330
|
-
|
355
|
+
refresh_token = request.cookies.get("refresh_token|" + str(global_int_app_id))
|
356
|
+
if refresh_token is None:
|
357
|
+
output_content = get_api_output_in_standard_format(
|
358
|
+
message=messages["REFRESH_TOKEN_NOT_FOUND"],
|
359
|
+
log=f"refresh token not found.",
|
360
|
+
)
|
361
|
+
return JSONResponse(
|
362
|
+
status_code=status.HTTP_400_BAD_REQUEST,
|
363
|
+
content=output_content,
|
364
|
+
)
|
365
|
+
refresh_token_payload = global_object_square_authentication_helper.validate_and_get_payload_from_token_v0(
|
366
|
+
refresh_token, TokenType.refresh_token
|
367
|
+
)[
|
368
|
+
"data"
|
369
|
+
][
|
370
|
+
"main"
|
371
|
+
]
|
372
|
+
if refresh_token_payload["app_id"] != global_int_app_id:
|
373
|
+
output_content = get_api_output_in_standard_format(
|
374
|
+
message=messages["INCORRECT_REFRESH_TOKEN"],
|
375
|
+
log=f"refresh token is for different app id. intended app id: {global_int_app_id}, actual app id: {refresh_token_payload['app_id']}.",
|
376
|
+
)
|
377
|
+
return JSONResponse(
|
378
|
+
status_code=status.HTTP_400_BAD_REQUEST,
|
379
|
+
content=output_content,
|
380
|
+
)
|
331
381
|
"""
|
332
382
|
main process
|
333
383
|
"""
|
{square_administration-2.1.0 → square_administration-2.2.1}/square_administration.egg-info/PKG-INFO
RENAMED
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: square-administration
|
3
|
-
Version: 2.1
|
3
|
+
Version: 2.2.1
|
4
4
|
Summary: common business layer for my personal server.
|
5
5
|
Home-page: https://github.com/thepmsquare/square_administration
|
6
6
|
Author: thePmSquare
|
@@ -32,6 +32,16 @@ pip install square_administration
|
|
32
32
|
|
33
33
|
## changelog
|
34
34
|
|
35
|
+
### v2.2.1
|
36
|
+
|
37
|
+
- authentication
|
38
|
+
- add validation for refresh token app id in logout_v0, generate_access_token_v0.
|
39
|
+
|
40
|
+
### v2.2.0
|
41
|
+
|
42
|
+
- authentication
|
43
|
+
- logout_v0, generate_access_token_v0 remove refresh token from request header and accept in cookie.
|
44
|
+
|
35
45
|
### v2.1.0
|
36
46
|
|
37
47
|
- add authentication -> logout_v0, generate_access_token_v0.
|
File without changes
|
{square_administration-2.1.0 → square_administration-2.2.1}/square_administration/__init__.py
RENAMED
File without changes
|
{square_administration-2.1.0 → square_administration-2.2.1}/square_administration/configuration.py
RENAMED
File without changes
|
{square_administration-2.1.0 → square_administration-2.2.1}/square_administration/data/config.ini
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{square_administration-2.1.0 → square_administration-2.2.1}/square_administration/routes/__init__.py
RENAMED
File without changes
|
{square_administration-2.1.0 → square_administration-2.2.1}/square_administration/routes/core.py
RENAMED
File without changes
|
{square_administration-2.1.0 → square_administration-2.2.1}/square_administration/utils/__init__.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|