square_authentication 11.2.2__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_authentication-11.2.2/PKG-INFO +70 -0
- square_authentication-11.2.2/README.md +28 -0
- square_authentication-11.2.2/pyproject.toml +53 -0
- square_authentication-11.2.2/square_authentication/__init__.py +0 -0
- square_authentication-11.2.2/square_authentication/configuration.py +175 -0
- square_authentication-11.2.2/square_authentication/data/config.sample.ini +72 -0
- square_authentication-11.2.2/square_authentication/data/config.testing.sample.ini +72 -0
- square_authentication-11.2.2/square_authentication/main.py +62 -0
- square_authentication-11.2.2/square_authentication/messages.py +32 -0
- square_authentication-11.2.2/square_authentication/pydantic_models/__init__.py +0 -0
- square_authentication-11.2.2/square_authentication/pydantic_models/core.py +228 -0
- square_authentication-11.2.2/square_authentication/pydantic_models/internal.py +5 -0
- square_authentication-11.2.2/square_authentication/pydantic_models/profile.py +35 -0
- square_authentication-11.2.2/square_authentication/routes/__init__.py +0 -0
- square_authentication-11.2.2/square_authentication/routes/core.py +609 -0
- square_authentication-11.2.2/square_authentication/routes/internal.py +37 -0
- square_authentication-11.2.2/square_authentication/routes/profile.py +147 -0
- square_authentication-11.2.2/square_authentication/utils/__init__.py +1 -0
- square_authentication-11.2.2/square_authentication/utils/core.py +37 -0
- square_authentication-11.2.2/square_authentication/utils/encryption.py +57 -0
- square_authentication-11.2.2/square_authentication/utils/routes/__init__.py +0 -0
- square_authentication-11.2.2/square_authentication/utils/routes/core.py +3600 -0
- square_authentication-11.2.2/square_authentication/utils/routes/internal.py +58 -0
- square_authentication-11.2.2/square_authentication/utils/routes/profile.py +688 -0
- square_authentication-11.2.2/square_authentication/utils/token.py +20 -0
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: square_authentication
|
|
3
|
+
Version: 11.2.2
|
|
4
|
+
Summary: authentication layer for my personal server.
|
|
5
|
+
Keywords: authentication,fastapi,server,utilities
|
|
6
|
+
Author: Parth Mukesh Mangtani
|
|
7
|
+
Author-email: Parth Mukesh Mangtani <thepmsquare@gmail.com>
|
|
8
|
+
License: GPLv3
|
|
9
|
+
Classifier: Development Status :: 3 - Alpha
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
16
|
+
Classifier: Topic :: Security
|
|
17
|
+
Classifier: Topic :: Internet :: WWW/HTTP :: HTTP Servers
|
|
18
|
+
Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
|
|
19
|
+
Classifier: Framework :: FastAPI
|
|
20
|
+
Requires-Dist: uvicorn>=0.24.0.post1
|
|
21
|
+
Requires-Dist: fastapi>=0.104.1
|
|
22
|
+
Requires-Dist: python-multipart>=0.0.6
|
|
23
|
+
Requires-Dist: pydantic>=2.5.3
|
|
24
|
+
Requires-Dist: bcrypt>=4.1.2
|
|
25
|
+
Requires-Dist: pyjwt>=2.8.0
|
|
26
|
+
Requires-Dist: requests>=2.32.3
|
|
27
|
+
Requires-Dist: cryptography>=42.0.7
|
|
28
|
+
Requires-Dist: square-commons>=3.1.0
|
|
29
|
+
Requires-Dist: square-logger>=3.0.0
|
|
30
|
+
Requires-Dist: square-database-helper>=2.7.1
|
|
31
|
+
Requires-Dist: square-database-structure>=2.6.0
|
|
32
|
+
Requires-Dist: square-file-store-helper>=3.1.1
|
|
33
|
+
Requires-Dist: httpx>=0.27.2
|
|
34
|
+
Requires-Dist: google-auth>=2.40.3
|
|
35
|
+
Requires-Dist: pytest>=8.3.3 ; extra == 'all'
|
|
36
|
+
Requires-Dist: pytest>=8.3.3 ; extra == 'dev'
|
|
37
|
+
Requires-Python: >=3.12
|
|
38
|
+
Project-URL: homepage, https://github.com/thepmsquare/square_authentication
|
|
39
|
+
Provides-Extra: all
|
|
40
|
+
Provides-Extra: dev
|
|
41
|
+
Description-Content-Type: text/markdown
|
|
42
|
+
|
|
43
|
+
# square_authentication
|
|
44
|
+
|
|
45
|
+
> 📌 versioning: see [CHANGELOG.md](./CHANGELOG.md).
|
|
46
|
+
|
|
47
|
+
## about
|
|
48
|
+
|
|
49
|
+
authentication layer for my personal server.
|
|
50
|
+
|
|
51
|
+
## goals
|
|
52
|
+
|
|
53
|
+
- integration with square_*
|
|
54
|
+
- unified authentication api across all projects
|
|
55
|
+
- jwt token support
|
|
56
|
+
- simple user and user profile management
|
|
57
|
+
- oauth support
|
|
58
|
+
- future extensibility
|
|
59
|
+
|
|
60
|
+
## Installation
|
|
61
|
+
|
|
62
|
+
```shell
|
|
63
|
+
pip install square_authentication
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## env
|
|
67
|
+
|
|
68
|
+
- python>=3.12.0
|
|
69
|
+
|
|
70
|
+
> feedback is appreciated. thank you!
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# square_authentication
|
|
2
|
+
|
|
3
|
+
> 📌 versioning: see [CHANGELOG.md](./CHANGELOG.md).
|
|
4
|
+
|
|
5
|
+
## about
|
|
6
|
+
|
|
7
|
+
authentication layer for my personal server.
|
|
8
|
+
|
|
9
|
+
## goals
|
|
10
|
+
|
|
11
|
+
- integration with square_*
|
|
12
|
+
- unified authentication api across all projects
|
|
13
|
+
- jwt token support
|
|
14
|
+
- simple user and user profile management
|
|
15
|
+
- oauth support
|
|
16
|
+
- future extensibility
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
```shell
|
|
21
|
+
pip install square_authentication
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## env
|
|
25
|
+
|
|
26
|
+
- python>=3.12.0
|
|
27
|
+
|
|
28
|
+
> feedback is appreciated. thank you!
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["uv-build"]
|
|
3
|
+
build-backend = "uv_build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "square_authentication"
|
|
7
|
+
version = "11.2.2"
|
|
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.1.0",
|
|
28
|
+
"square_logger>=3.0.0",
|
|
29
|
+
"square_database_helper>=2.7.1",
|
|
30
|
+
"square_database_structure>=2.6.0",
|
|
31
|
+
"square_file_store_helper>=3.1.1",
|
|
32
|
+
"httpx>=0.27.2",
|
|
33
|
+
"google-auth>=2.40.3",
|
|
34
|
+
]
|
|
35
|
+
optional-dependencies = { all = ["pytest>=8.3.3"], dev = ["pytest>=8.3.3"] }
|
|
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.uv.build-backend]
|
|
51
|
+
module-name = "square_authentication"
|
|
52
|
+
module-root = ""
|
|
53
|
+
source-include = ["square_authentication/data/*"]
|
|
File without changes
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import sys
|
|
3
|
+
|
|
4
|
+
from square_commons import ConfigReader
|
|
5
|
+
from square_database_helper import SquareDatabaseHelper
|
|
6
|
+
from square_file_store_helper import SquareFileStoreHelper
|
|
7
|
+
from square_logger.main import SquareLogger
|
|
8
|
+
|
|
9
|
+
try:
|
|
10
|
+
config_file_path = os.path.join(
|
|
11
|
+
os.path.dirname(os.path.abspath(__file__)), "data", "config.ini"
|
|
12
|
+
)
|
|
13
|
+
config_sample_file_path = os.path.join(
|
|
14
|
+
os.path.dirname(os.path.abspath(__file__)), "data", "config.sample.ini"
|
|
15
|
+
)
|
|
16
|
+
ldict_configuration = ConfigReader(
|
|
17
|
+
config_file_path, config_sample_file_path
|
|
18
|
+
).read_configuration()
|
|
19
|
+
|
|
20
|
+
# get all vars and typecast
|
|
21
|
+
# ===========================================
|
|
22
|
+
# general
|
|
23
|
+
config_str_module_name = ldict_configuration["GENERAL"]["MODULE_NAME"]
|
|
24
|
+
# ===========================================
|
|
25
|
+
|
|
26
|
+
# ===========================================
|
|
27
|
+
# environment
|
|
28
|
+
config_str_host_ip = ldict_configuration["ENVIRONMENT"]["HOST_IP"]
|
|
29
|
+
config_int_host_port = int(ldict_configuration["ENVIRONMENT"]["HOST_PORT"])
|
|
30
|
+
config_list_allow_origins = eval(
|
|
31
|
+
ldict_configuration["ENVIRONMENT"]["ALLOW_ORIGINS"]
|
|
32
|
+
)
|
|
33
|
+
config_str_log_file_name = ldict_configuration["ENVIRONMENT"]["LOG_FILE_NAME"]
|
|
34
|
+
config_str_secret_key_for_access_token = ldict_configuration["ENVIRONMENT"][
|
|
35
|
+
"SECRET_KEY_FOR_ACCESS_TOKEN"
|
|
36
|
+
]
|
|
37
|
+
config_str_secret_key_for_refresh_token = ldict_configuration["ENVIRONMENT"][
|
|
38
|
+
"SECRET_KEY_FOR_REFRESH_TOKEN"
|
|
39
|
+
]
|
|
40
|
+
config_int_access_token_valid_minutes = int(
|
|
41
|
+
ldict_configuration["ENVIRONMENT"]["ACCESS_TOKEN_VALID_MINUTES"]
|
|
42
|
+
)
|
|
43
|
+
config_int_refresh_token_valid_minutes = int(
|
|
44
|
+
ldict_configuration["ENVIRONMENT"]["REFRESH_TOKEN_VALID_MINUTES"]
|
|
45
|
+
)
|
|
46
|
+
config_str_ssl_crt_file_path = ldict_configuration["ENVIRONMENT"][
|
|
47
|
+
"SSL_CRT_FILE_PATH"
|
|
48
|
+
]
|
|
49
|
+
config_str_ssl_key_file_path = ldict_configuration["ENVIRONMENT"][
|
|
50
|
+
"SSL_KEY_FILE_PATH"
|
|
51
|
+
]
|
|
52
|
+
config_str_db_ip = ldict_configuration["ENVIRONMENT"]["DB_IP"]
|
|
53
|
+
|
|
54
|
+
config_int_db_port = int(ldict_configuration["ENVIRONMENT"]["DB_PORT"])
|
|
55
|
+
|
|
56
|
+
config_str_db_username = ldict_configuration["ENVIRONMENT"]["DB_USERNAME"]
|
|
57
|
+
|
|
58
|
+
config_str_db_password = ldict_configuration["ENVIRONMENT"]["DB_PASSWORD"]
|
|
59
|
+
# ===========================================
|
|
60
|
+
|
|
61
|
+
# ===========================================
|
|
62
|
+
# square_logger
|
|
63
|
+
config_int_log_level = int(ldict_configuration["SQUARE_LOGGER"]["LOG_LEVEL"])
|
|
64
|
+
config_str_log_path = ldict_configuration["SQUARE_LOGGER"]["LOG_PATH"]
|
|
65
|
+
config_int_log_backup_count = int(
|
|
66
|
+
ldict_configuration["SQUARE_LOGGER"]["LOG_BACKUP_COUNT"]
|
|
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
|
+
)
|
|
74
|
+
# ===========================================
|
|
75
|
+
|
|
76
|
+
# ===========================================
|
|
77
|
+
# square_database_helper
|
|
78
|
+
|
|
79
|
+
config_str_square_database_protocol = ldict_configuration["SQUARE_DATABASE_HELPER"][
|
|
80
|
+
"SQUARE_DATABASE_PROTOCOL"
|
|
81
|
+
]
|
|
82
|
+
config_str_square_database_ip = ldict_configuration["SQUARE_DATABASE_HELPER"][
|
|
83
|
+
"SQUARE_DATABASE_IP"
|
|
84
|
+
]
|
|
85
|
+
config_int_square_database_port = int(
|
|
86
|
+
ldict_configuration["SQUARE_DATABASE_HELPER"]["SQUARE_DATABASE_PORT"]
|
|
87
|
+
)
|
|
88
|
+
# ===========================================
|
|
89
|
+
|
|
90
|
+
# ===========================================
|
|
91
|
+
# square_file_store_helper
|
|
92
|
+
|
|
93
|
+
config_str_square_file_store_protocol = ldict_configuration[
|
|
94
|
+
"SQUARE_FILE_STORE_HELPER"
|
|
95
|
+
]["SQUARE_FILE_STORE_PROTOCOL"]
|
|
96
|
+
config_str_square_file_store_ip = ldict_configuration["SQUARE_FILE_STORE_HELPER"][
|
|
97
|
+
"SQUARE_FILE_STORE_IP"
|
|
98
|
+
]
|
|
99
|
+
config_int_square_file_store_port = int(
|
|
100
|
+
ldict_configuration["SQUARE_FILE_STORE_HELPER"]["SQUARE_FILE_STORE_PORT"]
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
# ===========================================
|
|
104
|
+
|
|
105
|
+
# ===========================================
|
|
106
|
+
# EMAIL
|
|
107
|
+
|
|
108
|
+
MAIL_GUN_API_KEY = ldict_configuration["EMAIL"]["MAIL_GUN_API_KEY"]
|
|
109
|
+
# ===========================================
|
|
110
|
+
# ===========================================
|
|
111
|
+
# GOOGLE
|
|
112
|
+
|
|
113
|
+
GOOGLE_AUTH_PLATFORM_CLIENT_ID = ldict_configuration["GOOGLE"][
|
|
114
|
+
"GOOGLE_AUTH_PLATFORM_CLIENT_ID"
|
|
115
|
+
]
|
|
116
|
+
# ===========================================
|
|
117
|
+
# ===========================================
|
|
118
|
+
# LOGIC
|
|
119
|
+
|
|
120
|
+
NUMBER_OF_RECOVERY_CODES = int(
|
|
121
|
+
ldict_configuration["LOGIC"]["NUMBER_OF_RECOVERY_CODES"]
|
|
122
|
+
)
|
|
123
|
+
EXPIRY_TIME_FOR_EMAIL_VERIFICATION_CODE_IN_SECONDS = int(
|
|
124
|
+
ldict_configuration["LOGIC"][
|
|
125
|
+
"EXPIRY_TIME_FOR_EMAIL_VERIFICATION_CODE_IN_SECONDS"
|
|
126
|
+
]
|
|
127
|
+
)
|
|
128
|
+
NUMBER_OF_DIGITS_IN_EMAIL_VERIFICATION_CODE = int(
|
|
129
|
+
ldict_configuration["LOGIC"]["NUMBER_OF_DIGITS_IN_EMAIL_VERIFICATION_CODE"]
|
|
130
|
+
)
|
|
131
|
+
EXPIRY_TIME_FOR_EMAIL_PASSWORD_RESET_CODE_IN_SECONDS = int(
|
|
132
|
+
ldict_configuration["LOGIC"][
|
|
133
|
+
"EXPIRY_TIME_FOR_EMAIL_PASSWORD_RESET_CODE_IN_SECONDS"
|
|
134
|
+
]
|
|
135
|
+
)
|
|
136
|
+
NUMBER_OF_DIGITS_IN_EMAIL_PASSWORD_RESET_CODE = int(
|
|
137
|
+
ldict_configuration["LOGIC"]["NUMBER_OF_DIGITS_IN_EMAIL_PASSWORD_RESET_CODE"]
|
|
138
|
+
)
|
|
139
|
+
RESEND_COOL_DOWN_TIME_FOR_EMAIL_VERIFICATION_CODE_IN_SECONDS = int(
|
|
140
|
+
ldict_configuration["LOGIC"][
|
|
141
|
+
"RESEND_COOL_DOWN_TIME_FOR_EMAIL_VERIFICATION_CODE_IN_SECONDS"
|
|
142
|
+
]
|
|
143
|
+
)
|
|
144
|
+
RESEND_COOL_DOWN_TIME_FOR_EMAIL_PASSWORD_RESET_CODE_IN_SECONDS = int(
|
|
145
|
+
ldict_configuration["LOGIC"][
|
|
146
|
+
"RESEND_COOL_DOWN_TIME_FOR_EMAIL_PASSWORD_RESET_CODE_IN_SECONDS"
|
|
147
|
+
]
|
|
148
|
+
)
|
|
149
|
+
# ===========================================
|
|
150
|
+
|
|
151
|
+
# Initialize logger
|
|
152
|
+
global_object_square_logger = SquareLogger(
|
|
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,
|
|
159
|
+
)
|
|
160
|
+
global_object_square_database_helper = SquareDatabaseHelper(
|
|
161
|
+
param_str_square_database_ip=config_str_square_database_ip,
|
|
162
|
+
param_int_square_database_port=config_int_square_database_port,
|
|
163
|
+
param_str_square_database_protocol=config_str_square_database_protocol,
|
|
164
|
+
)
|
|
165
|
+
global_object_square_file_store_helper = SquareFileStoreHelper(
|
|
166
|
+
param_str_square_file_store_protocol=config_str_square_file_store_protocol,
|
|
167
|
+
param_str_square_file_store_ip=config_str_square_file_store_ip,
|
|
168
|
+
param_int_square_file_store_port=config_int_square_file_store_port,
|
|
169
|
+
)
|
|
170
|
+
except Exception as e:
|
|
171
|
+
print(
|
|
172
|
+
"\033[91mMissing or incorrect config.ini file.\n"
|
|
173
|
+
"Error details: " + str(e) + "\033[0m"
|
|
174
|
+
)
|
|
175
|
+
sys.exit()
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
[GENERAL]
|
|
2
|
+
MODULE_NAME = square_authentication
|
|
3
|
+
|
|
4
|
+
[ENVIRONMENT]
|
|
5
|
+
HOST_IP = 0.0.0.0
|
|
6
|
+
HOST_PORT = 10011
|
|
7
|
+
ALLOW_ORIGINS = ["http://localhost:10011"]
|
|
8
|
+
|
|
9
|
+
LOG_FILE_NAME = square_authentication
|
|
10
|
+
|
|
11
|
+
SECRET_KEY_FOR_ACCESS_TOKEN = dummy_access
|
|
12
|
+
SECRET_KEY_FOR_REFRESH_TOKEN = dummy_refresh
|
|
13
|
+
|
|
14
|
+
ACCESS_TOKEN_VALID_MINUTES = 1440
|
|
15
|
+
REFRESH_TOKEN_VALID_MINUTES = 10080
|
|
16
|
+
|
|
17
|
+
# absolute path (mandatory only for http)
|
|
18
|
+
SSL_CRT_FILE_PATH = ssl.crt
|
|
19
|
+
SSL_KEY_FILE_PATH = ssl.key
|
|
20
|
+
|
|
21
|
+
DB_IP = localhost
|
|
22
|
+
DB_PORT = 10001
|
|
23
|
+
DB_USERNAME = postgres
|
|
24
|
+
DB_PASSWORD = dummy
|
|
25
|
+
|
|
26
|
+
[SQUARE_LOGGER]
|
|
27
|
+
|
|
28
|
+
# | Log Level | Value |
|
|
29
|
+
# | --------- | ----- |
|
|
30
|
+
# | CRITICAL | 50 |
|
|
31
|
+
# | ERROR | 40 |
|
|
32
|
+
# | WARNING | 30 |
|
|
33
|
+
# | INFO | 20 |
|
|
34
|
+
# | DEBUG | 10 |
|
|
35
|
+
# | NOTSET | 0 |
|
|
36
|
+
|
|
37
|
+
LOG_LEVEL = 20
|
|
38
|
+
# absolute or relative path
|
|
39
|
+
LOG_PATH = logs
|
|
40
|
+
# number of backup log files to keep during rotation
|
|
41
|
+
# if backupCount is zero, rollover never occurs.
|
|
42
|
+
LOG_BACKUP_COUNT = 3
|
|
43
|
+
# json or human_readable
|
|
44
|
+
FORMATTER_CHOICE = json
|
|
45
|
+
ENABLE_REDACTION = True
|
|
46
|
+
|
|
47
|
+
[SQUARE_DATABASE_HELPER]
|
|
48
|
+
|
|
49
|
+
SQUARE_DATABASE_PROTOCOL = http
|
|
50
|
+
SQUARE_DATABASE_IP = localhost
|
|
51
|
+
SQUARE_DATABASE_PORT = 10010
|
|
52
|
+
|
|
53
|
+
[SQUARE_FILE_STORE_HELPER]
|
|
54
|
+
|
|
55
|
+
SQUARE_FILE_STORE_PROTOCOL = http
|
|
56
|
+
SQUARE_FILE_STORE_IP = localhost
|
|
57
|
+
SQUARE_FILE_STORE_PORT = 10100
|
|
58
|
+
|
|
59
|
+
[EMAIL]
|
|
60
|
+
MAIL_GUN_API_KEY = dummy_mailgun_api_key
|
|
61
|
+
|
|
62
|
+
[GOOGLE]
|
|
63
|
+
GOOGLE_AUTH_PLATFORM_CLIENT_ID = dummy_google_client_id
|
|
64
|
+
|
|
65
|
+
[LOGIC]
|
|
66
|
+
NUMBER_OF_RECOVERY_CODES = 10
|
|
67
|
+
EXPIRY_TIME_FOR_EMAIL_VERIFICATION_CODE_IN_SECONDS = 600
|
|
68
|
+
NUMBER_OF_DIGITS_IN_EMAIL_VERIFICATION_CODE = 6
|
|
69
|
+
EXPIRY_TIME_FOR_EMAIL_PASSWORD_RESET_CODE_IN_SECONDS = 600
|
|
70
|
+
NUMBER_OF_DIGITS_IN_EMAIL_PASSWORD_RESET_CODE = 6
|
|
71
|
+
RESEND_COOL_DOWN_TIME_FOR_EMAIL_VERIFICATION_CODE_IN_SECONDS = 60
|
|
72
|
+
RESEND_COOL_DOWN_TIME_FOR_EMAIL_PASSWORD_RESET_CODE_IN_SECONDS = 60
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
[GENERAL]
|
|
2
|
+
MODULE_NAME = square_authentication
|
|
3
|
+
|
|
4
|
+
[ENVIRONMENT]
|
|
5
|
+
HOST_IP = 0.0.0.0
|
|
6
|
+
HOST_PORT = 10011
|
|
7
|
+
ALLOW_ORIGINS = ["http://localhost:10011"]
|
|
8
|
+
|
|
9
|
+
LOG_FILE_NAME = square_authentication
|
|
10
|
+
|
|
11
|
+
SECRET_KEY_FOR_ACCESS_TOKEN = dummy_access
|
|
12
|
+
SECRET_KEY_FOR_REFRESH_TOKEN = dummy_refresh
|
|
13
|
+
|
|
14
|
+
ACCESS_TOKEN_VALID_MINUTES = 1440
|
|
15
|
+
REFRESH_TOKEN_VALID_MINUTES = 10080
|
|
16
|
+
|
|
17
|
+
# absolute path (mandatory only for http)
|
|
18
|
+
SSL_CRT_FILE_PATH = ssl.crt
|
|
19
|
+
SSL_KEY_FILE_PATH = ssl.key
|
|
20
|
+
|
|
21
|
+
DB_IP = raspi.thepmsquare.com
|
|
22
|
+
DB_PORT = 15432
|
|
23
|
+
DB_USERNAME = postgres
|
|
24
|
+
DB_PASSWORD = testing_password
|
|
25
|
+
|
|
26
|
+
[SQUARE_LOGGER]
|
|
27
|
+
|
|
28
|
+
# | Log Level | Value |
|
|
29
|
+
# | --------- | ----- |
|
|
30
|
+
# | CRITICAL | 50 |
|
|
31
|
+
# | ERROR | 40 |
|
|
32
|
+
# | WARNING | 30 |
|
|
33
|
+
# | INFO | 20 |
|
|
34
|
+
# | DEBUG | 10 |
|
|
35
|
+
# | NOTSET | 0 |
|
|
36
|
+
|
|
37
|
+
LOG_LEVEL = 20
|
|
38
|
+
# absolute or relative path
|
|
39
|
+
LOG_PATH = logs
|
|
40
|
+
# number of backup log files to keep during rotation
|
|
41
|
+
# if backupCount is zero, rollover never occurs.
|
|
42
|
+
LOG_BACKUP_COUNT = 3
|
|
43
|
+
# json or human_readable
|
|
44
|
+
FORMATTER_CHOICE = json
|
|
45
|
+
ENABLE_REDACTION = True
|
|
46
|
+
|
|
47
|
+
[SQUARE_DATABASE_HELPER]
|
|
48
|
+
|
|
49
|
+
SQUARE_DATABASE_PROTOCOL = http
|
|
50
|
+
SQUARE_DATABASE_IP = raspi.thepmsquare.com
|
|
51
|
+
SQUARE_DATABASE_PORT = 20010
|
|
52
|
+
|
|
53
|
+
[SQUARE_FILE_STORE_HELPER]
|
|
54
|
+
|
|
55
|
+
SQUARE_FILE_STORE_PROTOCOL = http
|
|
56
|
+
SQUARE_FILE_STORE_IP = raspi.thepmsquare.com
|
|
57
|
+
SQUARE_FILE_STORE_PORT = 20010
|
|
58
|
+
|
|
59
|
+
[EMAIL]
|
|
60
|
+
MAIL_GUN_API_KEY = dummy_mailgun_api_key
|
|
61
|
+
|
|
62
|
+
[GOOGLE]
|
|
63
|
+
GOOGLE_AUTH_PLATFORM_CLIENT_ID = dummy_google_client_id
|
|
64
|
+
|
|
65
|
+
[LOGIC]
|
|
66
|
+
NUMBER_OF_RECOVERY_CODES = 10
|
|
67
|
+
EXPIRY_TIME_FOR_EMAIL_VERIFICATION_CODE_IN_SECONDS = 600
|
|
68
|
+
NUMBER_OF_DIGITS_IN_EMAIL_VERIFICATION_CODE = 6
|
|
69
|
+
EXPIRY_TIME_FOR_EMAIL_PASSWORD_RESET_CODE_IN_SECONDS = 600
|
|
70
|
+
NUMBER_OF_DIGITS_IN_EMAIL_PASSWORD_RESET_CODE = 6
|
|
71
|
+
RESEND_COOL_DOWN_TIME_FOR_EMAIL_VERIFICATION_CODE_IN_SECONDS = 60
|
|
72
|
+
RESEND_COOL_DOWN_TIME_FOR_EMAIL_PASSWORD_RESET_CODE_IN_SECONDS = 60
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import os.path
|
|
2
|
+
|
|
3
|
+
from fastapi import FastAPI, status
|
|
4
|
+
from fastapi.middleware.cors import CORSMiddleware
|
|
5
|
+
from fastapi.responses import JSONResponse
|
|
6
|
+
from square_commons import get_api_output_in_standard_format
|
|
7
|
+
from uvicorn import run
|
|
8
|
+
|
|
9
|
+
from square_authentication.configuration import (
|
|
10
|
+
config_int_host_port,
|
|
11
|
+
config_str_host_ip,
|
|
12
|
+
global_object_square_logger,
|
|
13
|
+
config_str_module_name,
|
|
14
|
+
config_str_ssl_key_file_path,
|
|
15
|
+
config_str_ssl_crt_file_path,
|
|
16
|
+
config_list_allow_origins,
|
|
17
|
+
)
|
|
18
|
+
from square_authentication.routes import core, internal, profile
|
|
19
|
+
|
|
20
|
+
app = FastAPI()
|
|
21
|
+
|
|
22
|
+
app.add_middleware(
|
|
23
|
+
CORSMiddleware,
|
|
24
|
+
allow_credentials=True,
|
|
25
|
+
allow_origins=config_list_allow_origins,
|
|
26
|
+
allow_methods=["*"],
|
|
27
|
+
allow_headers=["*"],
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
app.include_router(core.router)
|
|
31
|
+
app.include_router(internal.router)
|
|
32
|
+
app.include_router(profile.router)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
@app.get("/")
|
|
36
|
+
@global_object_square_logger.auto_logger()
|
|
37
|
+
async def root():
|
|
38
|
+
output_content = get_api_output_in_standard_format(log=config_str_module_name)
|
|
39
|
+
return JSONResponse(status_code=status.HTTP_200_OK, content=output_content)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
if __name__ == "__main__":
|
|
43
|
+
try:
|
|
44
|
+
if os.path.exists(config_str_ssl_key_file_path) and os.path.exists(
|
|
45
|
+
config_str_ssl_crt_file_path
|
|
46
|
+
):
|
|
47
|
+
run(
|
|
48
|
+
app,
|
|
49
|
+
host=config_str_host_ip,
|
|
50
|
+
port=config_int_host_port,
|
|
51
|
+
ssl_certfile=config_str_ssl_crt_file_path,
|
|
52
|
+
ssl_keyfile=config_str_ssl_key_file_path,
|
|
53
|
+
)
|
|
54
|
+
else:
|
|
55
|
+
run(
|
|
56
|
+
app,
|
|
57
|
+
host=config_str_host_ip,
|
|
58
|
+
port=config_int_host_port,
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
except Exception as exc:
|
|
62
|
+
global_object_square_logger.logger.critical(exc, exc_info=True)
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
messages = {
|
|
2
|
+
"REGISTRATION_SUCCESSFUL": "registration was successful. welcome aboard!",
|
|
3
|
+
"LOGIN_SUCCESSFUL": "you have logged in successfully.",
|
|
4
|
+
"LOGOUT_SUCCESSFUL": "you have logged out successfully.",
|
|
5
|
+
"INCORRECT_USERNAME": "the username you entered does not exist.",
|
|
6
|
+
"INCORRECT_PASSWORD": "the password you entered is incorrect. please try again.",
|
|
7
|
+
"INCORRECT_USER_ID": "the user ID you provided does not exist or is invalid.",
|
|
8
|
+
"USERNAME_INVALID": "username must start and end with a lowercase letter and can include only lowercase letters, digits, underscores, or hyphens. no spaces, no dots, and no consecutive special characters.",
|
|
9
|
+
"USERNAME_ALREADY_EXISTS": "the username you entered is already taken. please choose a different one.",
|
|
10
|
+
"INCORRECT_ACCESS_TOKEN": "the access token provided is invalid or expired.",
|
|
11
|
+
"INCORRECT_REFRESH_TOKEN": "the refresh token provided is invalid or expired.",
|
|
12
|
+
"GENERIC_CREATION_SUCCESSFUL": "records created successfully.",
|
|
13
|
+
"GENERIC_READ_SUCCESSFUL": "data retrieved successfully.",
|
|
14
|
+
"GENERIC_UPDATE_SUCCESSFUL": "your information has been updated successfully.",
|
|
15
|
+
"GENERIC_DELETE_SUCCESSFUL": "your records have been deleted successfully.",
|
|
16
|
+
"GENERIC_ACTION_SUCCESSFUL": "the action was completed successfully.",
|
|
17
|
+
"GENERIC_400": "the request is invalid or cannot be processed.",
|
|
18
|
+
"GENERIC_500": "an internal server error occurred. please try again later.",
|
|
19
|
+
"INVALID_FILE_FORMAT": "the file format is not supported. please upload a valid file.",
|
|
20
|
+
"FILE_SIZE_EXCEEDS_LIMIT": "the file size exceeds the limit. please upload a smaller file.",
|
|
21
|
+
"INCORRECT_AUTH_PROVIDER": "you have not linked this authentication provider to your account. please link it first.",
|
|
22
|
+
"INVALID_EMAIL_FORMAT": "the email address is invalid. please provide a valid email address.",
|
|
23
|
+
"INVALID_PHONE_NUMBER_FORMAT": "the phone number is invalid. please provide a valid phone number.",
|
|
24
|
+
"GENERIC_MISSING_REQUIRED_FIELD": "a required field is missing. please check your input and try again.",
|
|
25
|
+
"RECOVERY_METHOD_NOT_ENABLED": "the recovery method you are trying to use is not enabled for your account.",
|
|
26
|
+
"INCORRECT_BACKUP_CODE": "the backup code you provided is incorrect or has already been used. please try again with a valid code.",
|
|
27
|
+
"EMAIL_ALREADY_VERIFIED": "your email address has already been verified.",
|
|
28
|
+
"INCORRECT_VERIFICATION_CODE": "the verification code you entered is incorrect or has expired. please request a new code.",
|
|
29
|
+
"EMAIL_NOT_VERIFIED": "your email address has not been verified. please verify your email to continue.",
|
|
30
|
+
"ACCOUNT_WITH_EMAIL_ALREADY_EXISTS": "an account with this email address already exists.",
|
|
31
|
+
"MALFORMED_USER": " the user data is malformed or incomplete.",
|
|
32
|
+
}
|
|
File without changes
|