fastapi-rtk 0.2.27__py3-none-any.whl → 1.0.13__py3-none-any.whl

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 (98) hide show
  1. fastapi_rtk/__init__.py +39 -35
  2. fastapi_rtk/_version.py +1 -0
  3. fastapi_rtk/api/model_rest_api.py +476 -221
  4. fastapi_rtk/auth/auth.py +0 -9
  5. fastapi_rtk/backends/generic/__init__.py +6 -0
  6. fastapi_rtk/backends/generic/column.py +21 -12
  7. fastapi_rtk/backends/generic/db.py +42 -7
  8. fastapi_rtk/backends/generic/filters.py +21 -16
  9. fastapi_rtk/backends/generic/interface.py +14 -8
  10. fastapi_rtk/backends/generic/model.py +19 -11
  11. fastapi_rtk/backends/sqla/__init__.py +1 -0
  12. fastapi_rtk/backends/sqla/db.py +77 -17
  13. fastapi_rtk/backends/sqla/extensions/audit/audit.py +401 -189
  14. fastapi_rtk/backends/sqla/extensions/geoalchemy2/filters.py +15 -12
  15. fastapi_rtk/backends/sqla/filters.py +50 -21
  16. fastapi_rtk/backends/sqla/interface.py +96 -34
  17. fastapi_rtk/backends/sqla/model.py +56 -39
  18. fastapi_rtk/bases/__init__.py +20 -0
  19. fastapi_rtk/bases/db.py +94 -7
  20. fastapi_rtk/bases/file_manager.py +47 -3
  21. fastapi_rtk/bases/filter.py +22 -0
  22. fastapi_rtk/bases/interface.py +49 -5
  23. fastapi_rtk/bases/model.py +3 -0
  24. fastapi_rtk/bases/session.py +2 -0
  25. fastapi_rtk/cli/cli.py +62 -9
  26. fastapi_rtk/cli/commands/__init__.py +23 -0
  27. fastapi_rtk/cli/{db.py → commands/db/__init__.py} +107 -50
  28. fastapi_rtk/cli/{templates → commands/db/templates}/fastapi/env.py +2 -3
  29. fastapi_rtk/cli/{templates → commands/db/templates}/fastapi-multidb/env.py +10 -9
  30. fastapi_rtk/cli/{templates → commands/db/templates}/fastapi-multidb/script.py.mako +3 -1
  31. fastapi_rtk/cli/{export.py → commands/export.py} +12 -10
  32. fastapi_rtk/cli/{security.py → commands/security.py} +73 -7
  33. fastapi_rtk/cli/commands/translate.py +299 -0
  34. fastapi_rtk/cli/decorators.py +9 -4
  35. fastapi_rtk/cli/utils.py +46 -0
  36. fastapi_rtk/config.py +41 -1
  37. fastapi_rtk/const.py +29 -1
  38. fastapi_rtk/db.py +76 -40
  39. fastapi_rtk/decorators.py +1 -1
  40. fastapi_rtk/dependencies.py +134 -62
  41. fastapi_rtk/exceptions.py +51 -1
  42. fastapi_rtk/fastapi_react_toolkit.py +186 -171
  43. fastapi_rtk/file_managers/file_manager.py +8 -6
  44. fastapi_rtk/file_managers/s3_file_manager.py +69 -33
  45. fastapi_rtk/globals.py +22 -12
  46. fastapi_rtk/lang/__init__.py +3 -0
  47. fastapi_rtk/lang/babel/__init__.py +4 -0
  48. fastapi_rtk/lang/babel/cli.py +40 -0
  49. fastapi_rtk/lang/babel/config.py +17 -0
  50. fastapi_rtk/lang/babel.cfg +1 -0
  51. fastapi_rtk/lang/lazy_text.py +120 -0
  52. fastapi_rtk/lang/messages.pot +238 -0
  53. fastapi_rtk/lang/translations/de/LC_MESSAGES/messages.mo +0 -0
  54. fastapi_rtk/lang/translations/de/LC_MESSAGES/messages.po +248 -0
  55. fastapi_rtk/lang/translations/en/LC_MESSAGES/messages.mo +0 -0
  56. fastapi_rtk/lang/translations/en/LC_MESSAGES/messages.po +244 -0
  57. fastapi_rtk/manager.py +355 -37
  58. fastapi_rtk/mixins.py +12 -0
  59. fastapi_rtk/routers.py +208 -72
  60. fastapi_rtk/schemas.py +142 -39
  61. fastapi_rtk/security/sqla/apis.py +39 -13
  62. fastapi_rtk/security/sqla/models.py +8 -23
  63. fastapi_rtk/security/sqla/security_manager.py +369 -11
  64. fastapi_rtk/setting.py +446 -88
  65. fastapi_rtk/types.py +94 -27
  66. fastapi_rtk/utils/__init__.py +8 -0
  67. fastapi_rtk/utils/async_task_runner.py +286 -61
  68. fastapi_rtk/utils/csv_json_converter.py +243 -40
  69. fastapi_rtk/utils/hooks.py +34 -0
  70. fastapi_rtk/utils/merge_schema.py +3 -3
  71. fastapi_rtk/utils/multiple_async_contexts.py +21 -0
  72. fastapi_rtk/utils/pydantic.py +46 -1
  73. fastapi_rtk/utils/run_utils.py +31 -1
  74. fastapi_rtk/utils/self_dependencies.py +1 -1
  75. fastapi_rtk/utils/use_default_when_none.py +1 -1
  76. fastapi_rtk/version.py +6 -1
  77. fastapi_rtk-1.0.13.dist-info/METADATA +28 -0
  78. fastapi_rtk-1.0.13.dist-info/RECORD +133 -0
  79. {fastapi_rtk-0.2.27.dist-info → fastapi_rtk-1.0.13.dist-info}/WHEEL +1 -2
  80. fastapi_rtk/backends/gremlinpython/__init__.py +0 -108
  81. fastapi_rtk/backends/gremlinpython/column.py +0 -208
  82. fastapi_rtk/backends/gremlinpython/db.py +0 -228
  83. fastapi_rtk/backends/gremlinpython/exceptions.py +0 -34
  84. fastapi_rtk/backends/gremlinpython/filters.py +0 -461
  85. fastapi_rtk/backends/gremlinpython/interface.py +0 -734
  86. fastapi_rtk/backends/gremlinpython/model.py +0 -364
  87. fastapi_rtk/backends/gremlinpython/session.py +0 -23
  88. fastapi_rtk/cli/commands.py +0 -295
  89. fastapi_rtk-0.2.27.dist-info/METADATA +0 -23
  90. fastapi_rtk-0.2.27.dist-info/RECORD +0 -126
  91. fastapi_rtk-0.2.27.dist-info/top_level.txt +0 -1
  92. /fastapi_rtk/cli/{templates → commands/db/templates}/fastapi/README +0 -0
  93. /fastapi_rtk/cli/{templates → commands/db/templates}/fastapi/alembic.ini.mako +0 -0
  94. /fastapi_rtk/cli/{templates → commands/db/templates}/fastapi/script.py.mako +0 -0
  95. /fastapi_rtk/cli/{templates → commands/db/templates}/fastapi-multidb/README +0 -0
  96. /fastapi_rtk/cli/{templates → commands/db/templates}/fastapi-multidb/alembic.ini.mako +0 -0
  97. {fastapi_rtk-0.2.27.dist-info → fastapi_rtk-1.0.13.dist-info}/entry_points.txt +0 -0
  98. {fastapi_rtk-0.2.27.dist-info → fastapi_rtk-1.0.13.dist-info}/licenses/LICENSE +0 -0
fastapi_rtk/setting.py CHANGED
@@ -1,12 +1,19 @@
1
1
  import typing
2
2
 
3
3
  from .const import (
4
+ DEFAULT_ADMIN_ROLE,
4
5
  DEFAULT_API_MAX_PAGE_SIZE,
6
+ DEFAULT_LANG_FOLDER,
7
+ DEFAULT_LANGUAGES,
5
8
  DEFAULT_PROFILER_FOLDER,
9
+ DEFAULT_PUBLIC_ROLE,
6
10
  DEFAULT_STATIC_FOLDER,
7
11
  DEFAULT_TEMPLATE_FOLDER,
12
+ DEFAULT_TRANSLATIONS_KEY,
13
+ AuthType,
8
14
  logger,
9
15
  )
16
+ from .exceptions import FastAPIReactToolkitException
10
17
  from .globals import g
11
18
 
12
19
  if typing.TYPE_CHECKING:
@@ -20,43 +27,68 @@ logger = logger.getChild("setting")
20
27
 
21
28
  class _Setting:
22
29
  """
23
- A static class to have an overview of the settings of the FastAPI application. It is designed to be used as a static class and as a single source of truth for the settings.
30
+ A static class to have an overview of the settings of the FastAPI React Toolkit application. It is designed to be used as a static class and as a single source of truth for the settings.
24
31
 
25
32
  This `Setting` is useful for documentation purposes, as it provides a clear overview of the settings available in the application. It is not intended to be used as a configuration manager or to modify the settings at runtime.
26
33
  """
27
34
 
35
+ """
36
+ --------------------------------------------------------------------------------------------------------
37
+ GENERAL SETTINGS
38
+ --------------------------------------------------------------------------------------------------------
39
+ """
40
+
28
41
  @property
29
- def SQLALCHEMY_DATABASE_URI(self) -> str | None:
30
- """
31
- SQLAlchemy database URI.
32
- """
33
- return g.config.get("SQLALCHEMY_DATABASE_URI")
42
+ def APP_NAME(self) -> str:
43
+ return g.config.get("APP_NAME", "FastAPI React Toolkit")
34
44
 
35
45
  @property
36
- def SQLALCHEMY_BINDS(self) -> dict[str, str] | None:
37
- """
38
- SQLAlchemy binds.
39
- """
40
- return g.config.get("SQLALCHEMY_BINDS")
46
+ def APP_SUMMARY(self) -> str | None:
47
+ return g.config.get("APP_SUMMARY")
41
48
 
42
49
  @property
43
- def SQLALCHEMY_ENGINE_OPTIONS(self) -> dict[str, typing.Any]:
44
- """
45
- SQLAlchemy engine options.
46
- """
47
- return g.config.get("SQLALCHEMY_ENGINE_OPTIONS", {})
50
+ def APP_DESCRIPTION(self) -> str | None:
51
+ return g.config.get("APP_DESCRIPTION")
48
52
 
49
53
  @property
50
- def SQLALCHEMY_ENGINE_OPTIONS_BINDS(self) -> dict[str, typing.Any]:
51
- """
52
- SQLAlchemy engine options for binds.
53
- """
54
- return g.config.get("SQLALCHEMY_ENGINE_OPTIONS_BINDS", {})
54
+ def APP_VERSION(self) -> str | None:
55
+ return g.config.get("APP_VERSION")
56
+
57
+ @property
58
+ def APP_OPENAPI_URL(self) -> str | None:
59
+ return g.config.get("APP_OPENAPI_URL")
55
60
 
56
61
  @property
57
62
  def ROLES(self) -> dict[str, list[list[str] | tuple[str, str]]]:
58
63
  return g.config.get("ROLES") or g.config.get("FAB_ROLES", {})
59
64
 
65
+ @property
66
+ def API_MAX_PAGE_SIZE(self) -> int:
67
+ return g.config.get(
68
+ "API_MAX_PAGE_SIZE",
69
+ g.config.get("FAB_API_MAX_PAGE_SIZE", DEFAULT_API_MAX_PAGE_SIZE),
70
+ )
71
+
72
+ @property
73
+ def TEXT_FILTER_SEPARATOR(self) -> str:
74
+ return g.config.get("TEXT_FILTER_SEPARATOR", ";")
75
+
76
+ @property
77
+ def DEBUG(self) -> bool:
78
+ return g.config.get("DEBUG", False)
79
+
80
+ @property
81
+ def BASE_PATH(self) -> str | None:
82
+ return g.config.get("BASE_PATH")
83
+
84
+ @property
85
+ def TEMPLATE_CONTEXT(self) -> dict[str, typing.Any]:
86
+ return g.config.get("TEMPLATE_CONTEXT", {})
87
+
88
+ @property
89
+ def FAB_REACT_CONFIG(self) -> dict[str, typing.Any]:
90
+ return g.config.get("FAB_REACT_CONFIG", {})
91
+
60
92
  @property
61
93
  def STATIC_FOLDER(self) -> str:
62
94
  return g.config.get("STATIC_FOLDER", DEFAULT_STATIC_FOLDER)
@@ -65,6 +97,18 @@ class _Setting:
65
97
  def TEMPLATE_FOLDER(self) -> str:
66
98
  return g.config.get("TEMPLATE_FOLDER", DEFAULT_TEMPLATE_FOLDER)
67
99
 
100
+ @property
101
+ def UPLOAD_FOLDER(self) -> str | None:
102
+ return g.config.get("UPLOAD_FOLDER")
103
+
104
+ @property
105
+ def IMG_UPLOAD_FOLDER(self) -> str | None:
106
+ return g.config.get("IMG_UPLOAD_FOLDER")
107
+
108
+ @property
109
+ def LANG_FOLDER(self) -> str:
110
+ return g.config.get("LANG_FOLDER", DEFAULT_LANG_FOLDER)
111
+
68
112
  @property
69
113
  def FILE_MANAGER(self) -> "AbstractFileManager | None":
70
114
  """
@@ -79,14 +123,6 @@ class _Setting:
79
123
  """
80
124
  return g.config.get("IMAGE_MANAGER")
81
125
 
82
- @property
83
- def UPLOAD_FOLDER(self) -> str | None:
84
- return g.config.get("UPLOAD_FOLDER")
85
-
86
- @property
87
- def IMG_UPLOAD_FOLDER(self) -> str | None:
88
- return g.config.get("IMG_UPLOAD_FOLDER")
89
-
90
126
  @property
91
127
  def FILE_ALLOWED_EXTENSIONS(self) -> list[str] | None:
92
128
  return g.config.get("FILE_ALLOWED_EXTENSIONS")
@@ -98,61 +134,94 @@ class _Setting:
98
134
  )
99
135
 
100
136
  @property
101
- def BASE_PATH(self) -> str | None:
102
- return g.config.get("BASE_PATH")
103
-
104
- @property
105
- def FAB_REACT_CONFIG(self) -> dict[str, typing.Any]:
106
- return g.config.get("FAB_REACT_CONFIG", {})
137
+ def LANGUAGES(self) -> str:
138
+ """
139
+ Languages to use for translations, separated by commas.
140
+ """
141
+ return g.config.get("LANGUAGES", DEFAULT_LANGUAGES)
107
142
 
108
143
  @property
109
- def PROFILER_ENABLED(self) -> bool:
144
+ def TRANSLATIONS(self) -> dict[str, dict[str, str]] | None:
110
145
  """
111
- Whether the profiler is enabled.
146
+ Translations to be sent to the frontend.
112
147
  """
113
- return g.config.get("PROFILER_ENABLED", False)
148
+ return g.config.get("TRANSLATIONS")
114
149
 
115
150
  @property
116
- def PROFILER_FOLDER(self) -> str:
151
+ def TRANSLATIONS_KEY(self) -> str:
117
152
  """
118
- The folder to store profiler files.
153
+ The key to use for the translations in the `FAB_REACT_CONFIG`.
119
154
  """
120
- return g.config.get("PROFILER_FOLDER", DEFAULT_PROFILER_FOLDER)
155
+ return g.config.get("TRANSLATIONS_KEY", DEFAULT_TRANSLATIONS_KEY)
121
156
 
122
157
  @property
123
- def PROFILER_TYPE(self) -> str:
158
+ def BABEL_OPTIONS(self) -> dict[str, typing.Any]:
124
159
  """
125
- The profiler type.
160
+ Babel options to pass to the `fastapi_babel.BabelConfigs` class.
126
161
  """
127
- return g.config.get("PROFILER_TYPE", "html")
162
+ return g.config.get("BABEL_OPTIONS", {})
163
+
164
+ """
165
+ --------------------------------------------------------------------------------------------------------
166
+ GENERAL SETTINGS - SecWeb
167
+ --------------------------------------------------------------------------------------------------------
168
+ """
128
169
 
129
170
  @property
130
- def PROFILER_RENDERER(self) -> str:
171
+ def SECWEB_ENABLED(self) -> bool:
172
+ return g.config.get("SECWEB_ENABLED", False)
173
+
174
+ @property
175
+ def SECWEB_PARAMS(self) -> dict[str, typing.Any]:
176
+ return g.config.get("SECWEB_PARAMS", {})
177
+
178
+ @property
179
+ def SECWEB_PATCH_DOCS(self) -> bool:
180
+ return g.config.get("SECWEB_PATCH_DOCS", True)
181
+
182
+ @property
183
+ def SECWEB_PATCH_REDOC(self) -> bool:
184
+ return g.config.get("SECWEB_PATCH_REDOC", True)
185
+
186
+ """
187
+ --------------------------------------------------------------------------------------------------------
188
+ GENERAL SETTINGS - Database
189
+ --------------------------------------------------------------------------------------------------------
190
+ """
191
+
192
+ @property
193
+ def SQLALCHEMY_DATABASE_URI(self) -> str | None:
131
194
  """
132
- The profiler renderer.
195
+ SQLAlchemy database URI.
133
196
  """
134
- return g.config.get("PROFILER_RENDERER", "HTMLRenderer")
197
+ return g.config.get("SQLALCHEMY_DATABASE_URI")
135
198
 
136
199
  @property
137
- def INSTRUMENTATOR_CONFIG(self) -> dict[str, typing.Any]:
200
+ def SQLALCHEMY_BINDS(self) -> dict[str, str] | None:
138
201
  """
139
- Instrumentator configuration.
202
+ SQLAlchemy binds.
140
203
  """
141
- return g.config.get("INSTRUMENTATOR_CONFIG", {})
204
+ return g.config.get("SQLALCHEMY_BINDS")
142
205
 
143
206
  @property
144
- def INSTRUMENTATOR_INSTRUMENT_CONFIG(self) -> dict[str, typing.Any]:
207
+ def SQLALCHEMY_ENGINE_OPTIONS(self) -> dict[str, typing.Any]:
145
208
  """
146
- Instrumentator instrument configuration.
209
+ SQLAlchemy engine options.
147
210
  """
148
- return g.config.get("INSTRUMENTATOR_INSTRUMENT_CONFIG", {})
211
+ return g.config.get("SQLALCHEMY_ENGINE_OPTIONS", {})
149
212
 
150
213
  @property
151
- def INSTRUMENTATOR_EXPOSE_CONFIG(self) -> dict[str, typing.Any]:
214
+ def SQLALCHEMY_ENGINE_OPTIONS_BINDS(self) -> dict[str, typing.Any]:
152
215
  """
153
- Instrumentator expose configuration.
216
+ SQLAlchemy engine options for binds.
154
217
  """
155
- return g.config.get("INSTRUMENTATOR_EXPOSE_CONFIG", {})
218
+ return g.config.get("SQLALCHEMY_ENGINE_OPTIONS_BINDS", {})
219
+
220
+ """
221
+ --------------------------------------------------------------------------------------------------------
222
+ GENERAL SETTINGS - Auth
223
+ --------------------------------------------------------------------------------------------------------
224
+ """
156
225
 
157
226
  @property
158
227
  def AUTH_LOGIN_COOKIE(self) -> bool:
@@ -178,15 +247,26 @@ class _Setting:
178
247
  def AUTH_USER_VERIFY(self) -> bool | None:
179
248
  return g.config.get("AUTH_USER_VERIFY")
180
249
 
250
+ @property
251
+ def AUTH_ROLE_ADMIN(self) -> typing.Optional[str]:
252
+ return g.config.get("AUTH_ROLE_ADMIN", DEFAULT_ADMIN_ROLE)
253
+
254
+ @property
255
+ def AUTH_ROLE_PUBLIC(self) -> typing.Optional[str]:
256
+ return g.config.get("AUTH_ROLE_PUBLIC", DEFAULT_PUBLIC_ROLE)
257
+
258
+ """
259
+ --------------------------------------------------------------------------------------------------------
260
+ GENERAL SETTINGS - Auth - OAuth
261
+ --------------------------------------------------------------------------------------------------------
262
+ """
263
+
181
264
  @property
182
265
  def AUTH_ROLES_MAPPING(self) -> dict[str, list[str]]:
183
266
  return g.config.get("AUTH_ROLES_MAPPING", {})
184
267
 
185
268
  @property
186
269
  def AUTH_ROLES_SYNC_AT_LOGIN(self) -> bool:
187
- logger.warning(
188
- "`AUTH_ROLES_SYNC_AT_LOGIN` is no longer used, please use `on_before_login` callback and set the `role_keys` to `user_dict` parameter."
189
- )
190
270
  return g.config.get("AUTH_ROLES_SYNC_AT_LOGIN", False)
191
271
 
192
272
  @property
@@ -197,60 +277,338 @@ class _Setting:
197
277
  def OAUTH_REDIRECT_URI(self) -> str | None:
198
278
  return g.config.get("OAUTH_REDIRECT_URI")
199
279
 
280
+ """
281
+ --------------------------------------------------------------------------------------------------------
282
+ GENERAL SETTINGS - Auth - LDAP
283
+ --------------------------------------------------------------------------------------------------------
284
+ """
285
+
200
286
  @property
201
- def API_MAX_PAGE_SIZE(self) -> int:
202
- return g.config.get(
203
- "API_MAX_PAGE_SIZE",
204
- g.config.get("FAB_API_MAX_PAGE_SIZE", DEFAULT_API_MAX_PAGE_SIZE),
205
- )
287
+ def AUTH_TYPE(self) -> str | None:
288
+ auth_type = g.config.get("AUTH_TYPE")
289
+ if auth_type == AuthType.LDAP:
290
+ if not self.AUTH_LDAP_SERVER:
291
+ raise FastAPIReactToolkitException(
292
+ f"AUTH_LDAP_SERVER must be set if AUTH_TYPE is {AuthType.LDAP}"
293
+ )
294
+ return auth_type
206
295
 
207
296
  @property
208
- def APP_NAME(self) -> str:
209
- return g.config.get("APP_NAME", "FastAPI React Toolkit")
297
+ def AUTH_LDAP_SERVER(self) -> str | None:
298
+ return g.config.get("AUTH_LDAP_SERVER")
210
299
 
211
300
  @property
212
- def APP_SUMMARY(self) -> str | None:
213
- return g.config.get("APP_SUMMARY")
301
+ def AUTH_LDAP_SEARCH(self) -> str | None:
302
+ return g.config.get("AUTH_LDAP_SEARCH")
214
303
 
215
304
  @property
216
- def APP_DESCRIPTION(self) -> str | None:
217
- return g.config.get("APP_DESCRIPTION")
305
+ def AUTH_LDAP_SEARCH_FILTER(self) -> str | None:
306
+ return g.config.get("AUTH_LDAP_SEARCH_FILTER")
218
307
 
219
308
  @property
220
- def APP_VERSION(self) -> str | None:
221
- return g.config.get("APP_VERSION")
309
+ def AUTH_LDAP_APPEND_DOMAIN(self) -> str | None:
310
+ return g.config.get("AUTH_LDAP_APPEND_DOMAIN")
222
311
 
223
312
  @property
224
- def APP_OPENAPI_URL(self) -> str | None:
225
- return g.config.get("APP_OPENAPI_URL")
313
+ def AUTH_LDAP_USERNAME_FORMAT(self) -> str | None:
314
+ return g.config.get("AUTH_LDAP_USERNAME_FORMAT")
226
315
 
227
316
  @property
228
- def TEXT_FILTER_SEPARATOR(self) -> str:
229
- return g.config.get("TEXT_FILTER_SEPARATOR", ";")
317
+ def AUTH_LDAP_UID_FIELD(self) -> str:
318
+ return g.config.get("AUTH_LDAP_UID_FIELD", "uid")
230
319
 
231
320
  @property
232
- def DEBUG(self) -> bool:
233
- return g.config.get("DEBUG", False)
321
+ def AUTH_LDAP_GROUP_FIELD(self) -> str:
322
+ return g.config.get("AUTH_LDAP_GROUP_FIELD", "memberOf")
234
323
 
235
324
  @property
236
- def SECWEB_ENABLED(self) -> bool:
237
- return g.config.get("SECWEB_ENABLED", False)
325
+ def AUTH_LDAP_FIRSTNAME_FIELD(self) -> str:
326
+ return g.config.get("AUTH_LDAP_FIRSTNAME_FIELD", "givenName")
238
327
 
239
328
  @property
240
- def SECWEB_PARAMS(self) -> dict[str, typing.Any]:
241
- return g.config.get("SECWEB_PARAMS", {})
329
+ def AUTH_LDAP_LASTNAME_FIELD(self) -> str:
330
+ return g.config.get("AUTH_LDAP_LASTNAME_FIELD", "sn")
242
331
 
243
332
  @property
244
- def SECWEB_PATCH_DOCS(self) -> bool:
245
- return g.config.get("SECWEB_PATCH_DOCS", True)
333
+ def AUTH_LDAP_EMAIL_FIELD(self) -> str:
334
+ return g.config.get("AUTH_LDAP_EMAIL_FIELD", "mail")
246
335
 
247
336
  @property
248
- def SECWEB_PATCH_REDOC(self) -> bool:
249
- return g.config.get("SECWEB_PATCH_REDOC", True)
337
+ def AUTH_LDAP_BIND_USER(self) -> str | None:
338
+ user = g.config.get("AUTH_LDAP_BIND_USER")
339
+ if user is not None:
340
+ if self.AUTH_LDAP_SEARCH is None:
341
+ raise FastAPIReactToolkitException(
342
+ "AUTH_LDAP_SEARCH must be set if AUTH_LDAP_BIND_USER is set"
343
+ )
344
+ return user
250
345
 
251
346
  @property
252
- def TEMPLATE_CONTEXT(self) -> dict[str, typing.Any]:
253
- return g.config.get("TEMPLATE_CONTEXT", {})
347
+ def AUTH_LDAP_BIND_PASSWORD(self) -> str | None:
348
+ return g.config.get("AUTH_LDAP_BIND_PASSWORD")
349
+
350
+ @property
351
+ def AUTH_LDAP_USE_TLS(self) -> bool:
352
+ return g.config.get("AUTH_LDAP_USE_TLS", False)
353
+
354
+ @property
355
+ def AUTH_LDAP_ALLOW_SELF_SIGNED(self) -> bool:
356
+ return g.config.get("AUTH_LDAP_ALLOW_SELF_SIGNED", False)
357
+
358
+ @property
359
+ def AUTH_LDAP_TLS_DEMAND(self) -> bool:
360
+ return g.config.get("AUTH_LDAP_TLS_DEMAND", False)
361
+
362
+ @property
363
+ def AUTH_LDAP_TLS_KEYFILE(self) -> str | None:
364
+ return g.config.get("AUTH_LDAP_TLS_KEYFILE")
365
+
366
+ @property
367
+ def AUTH_LDAP_TLS_CERTFILE(self) -> str | None:
368
+ return g.config.get("AUTH_LDAP_TLS_CERTFILE")
369
+
370
+ @property
371
+ def AUTH_LDAP_TLS_CACERTDIR(self) -> str | None:
372
+ return g.config.get("AUTH_LDAP_TLS_CACERTDIR")
373
+
374
+ @property
375
+ def AUTH_LDAP_TLS_CACERTFILE(self) -> str | None:
376
+ return g.config.get("AUTH_LDAP_TLS_CACERTFILE")
377
+
378
+ """
379
+ --------------------------------------------------------------------------------------------------------
380
+ CONFIG
381
+ --------------------------------------------------------------------------------------------------------
382
+ """
383
+
384
+ @property
385
+ def CONFIG_ENABLE_DEEP_MERGE(self) -> bool:
386
+ return g.config.get("CONFIG_ENABLE_DEEP_MERGE")
387
+
388
+ @property
389
+ def CONFIG_DEEP_MERGE_WHITELIST(self) -> list[str] | tuple[str] | None:
390
+ return g.config.get("CONFIG_DEEP_MERGE_WHITELIST")
391
+
392
+ """
393
+ --------------------------------------------------------------------------------------------------------
394
+ PROMETHEUS
395
+ --------------------------------------------------------------------------------------------------------
396
+ """
397
+
398
+ @property
399
+ def INSTRUMENTATOR_CONFIG(self) -> dict[str, typing.Any]:
400
+ """
401
+ Instrumentator configuration.
402
+ """
403
+ return g.config.get("INSTRUMENTATOR_CONFIG", {})
404
+
405
+ @property
406
+ def INSTRUMENTATOR_INSTRUMENT_CONFIG(self) -> dict[str, typing.Any]:
407
+ """
408
+ Instrumentator instrument configuration.
409
+ """
410
+ return g.config.get("INSTRUMENTATOR_INSTRUMENT_CONFIG", {})
411
+
412
+ @property
413
+ def INSTRUMENTATOR_EXPOSE_CONFIG(self) -> dict[str, typing.Any]:
414
+ """
415
+ Instrumentator expose configuration.
416
+ """
417
+ return g.config.get("INSTRUMENTATOR_EXPOSE_CONFIG", {})
418
+
419
+ """
420
+ --------------------------------------------------------------------------------------------------------
421
+ PyInstrument (Profiler)
422
+ --------------------------------------------------------------------------------------------------------
423
+ """
424
+
425
+ @property
426
+ def PROFILER_ENABLED(self) -> bool:
427
+ """
428
+ Whether the profiler is enabled.
429
+ """
430
+ return g.config.get("PROFILER_ENABLED", False)
431
+
432
+ @property
433
+ def PROFILER_TYPE(self) -> str:
434
+ """
435
+ The profiler type.
436
+ """
437
+ return g.config.get("PROFILER_TYPE", "html")
438
+
439
+ @property
440
+ def PROFILER_RENDERER(self) -> str:
441
+ """
442
+ The profiler renderer.
443
+ """
444
+ return g.config.get("PROFILER_RENDERER", "HTMLRenderer")
445
+
446
+ @property
447
+ def PROFILER_FOLDER(self) -> str:
448
+ """
449
+ The folder to store profiler files.
450
+ """
451
+ return g.config.get("PROFILER_FOLDER", DEFAULT_PROFILER_FOLDER)
452
+
453
+ """
454
+ --------------------------------------------------------------------------------------------------------
455
+ AUTH SETTINGS - `g.auth`
456
+ --------------------------------------------------------------------------------------------------------
457
+ """
458
+
459
+ @property
460
+ def PASSWORD_HELPER(self):
461
+ return g.config.get("PASSWORD_HELPER")
462
+
463
+ @property
464
+ def COOKIE_CONFIG(self):
465
+ return g.config.get("COOKIE_CONFIG")
466
+
467
+ @property
468
+ def BEARER_CONFIG(self):
469
+ return g.config.get("BEARER_CONFIG")
470
+
471
+ @property
472
+ def COOKIE_STRATEGY_CONFIG(self):
473
+ return g.config.get("COOKIE_STRATEGY_CONFIG")
474
+
475
+ @property
476
+ def BEARER_STRATEGY_CONFIG(self):
477
+ return g.config.get("BEARER_STRATEGY_CONFIG")
478
+
479
+ @property
480
+ def SECRET_KEY(self):
481
+ return g.config.get("SECRET_KEY")
482
+
483
+ @property
484
+ def USER_MANAGER(self):
485
+ return g.config.get("USER_MANAGER")
486
+
487
+ @property
488
+ def COOKIE_TRANSPORT(self):
489
+ return g.config.get("COOKIE_TRANSPORT")
490
+
491
+ @property
492
+ def BEARER_TRANSPORT(self):
493
+ return g.config.get("BEARER_TRANSPORT")
494
+
495
+ @property
496
+ def COOKIE_BACKEND(self):
497
+ return g.config.get("COOKIE_BACKEND")
498
+
499
+ @property
500
+ def BEARER_BACKEND(self):
501
+ return g.config.get("BEARER_BACKEND")
502
+
503
+ @property
504
+ def AUTHENTICATOR(self):
505
+ return g.config.get("AUTHENTICATOR")
506
+
507
+ @property
508
+ def FASTAPI_USERS(self):
509
+ return g.config.get("FASTAPI_USERS")
510
+
511
+ @property
512
+ def STRATEGY_BACKEND(self):
513
+ return g.config.get("STRATEGY_BACKEND")
514
+
515
+ """
516
+ --------------------------------------------------------------------------------------------------------
517
+ AUTH SETTINGS - `g.auth.cookie_config`
518
+ --------------------------------------------------------------------------------------------------------
519
+ """
520
+
521
+ @property
522
+ def COOKIE_NAME(self):
523
+ return g.config.get("COOKIE_NAME")
524
+
525
+ @property
526
+ def COOKIE_MAX_AGE(self):
527
+ return g.config.get("COOKIE_MAX_AGE")
528
+
529
+ @property
530
+ def COOKIE_PATH(self):
531
+ return g.config.get("COOKIE_PATH")
532
+
533
+ @property
534
+ def COOKIE_DOMAIN(self):
535
+ return g.config.get("COOKIE_DOMAIN")
536
+
537
+ @property
538
+ def COOKIE_SECURE(self):
539
+ return g.config.get("COOKIE_SECURE")
540
+
541
+ @property
542
+ def COOKIE_HTTPONLY(self):
543
+ return g.config.get("COOKIE_HTTPONLY")
544
+
545
+ @property
546
+ def COOKIE_SAMESITE(self):
547
+ return g.config.get("COOKIE_SAMESITE")
548
+
549
+ """
550
+ --------------------------------------------------------------------------------------------------------
551
+ AUTH SETTINGS - `g.auth.bearer_config`
552
+ --------------------------------------------------------------------------------------------------------
553
+ """
554
+
555
+ @property
556
+ def BEARER_TOKEN_URL(self):
557
+ return g.config.get("BEARER_TOKEN_URL")
558
+
559
+ """
560
+ --------------------------------------------------------------------------------------------------------
561
+ AUTH SETTINGS - `g.auth.cookie_strategy_config`
562
+ --------------------------------------------------------------------------------------------------------
563
+ """
564
+
565
+ @property
566
+ def COOKIE_LIFETIME_SECONDS(self):
567
+ return g.config.get("COOKIE_LIFETIME_SECONDS")
568
+
569
+ @property
570
+ def COOKIE_TOKEN_AUDIENCE(self):
571
+ """
572
+ ONLY WHEN STRATEGY_BACKEND = "JWT"
573
+ """
574
+ return g.config.get("COOKIE_TOKEN_AUDIENCE")
575
+
576
+ @property
577
+ def COOKIE_ALGORITHM(self):
578
+ """
579
+ ONLY WHEN STRATEGY_BACKEND = "JWT"
580
+ """
581
+ return g.config.get("COOKIE_ALGORITHM")
582
+
583
+ """
584
+ --------------------------------------------------------------------------------------------------------
585
+ AUTH SETTINGS - `g.auth.bearer_strategy_config`
586
+ --------------------------------------------------------------------------------------------------------
587
+ """
588
+
589
+ @property
590
+ def BEARER_LIFETIME_SECONDS(self):
591
+ return g.config.get("BEARER_LIFETIME_SECONDS")
592
+
593
+ @property
594
+ def BEARER_TOKEN_AUDIENCE(self):
595
+ """
596
+ ONLY WHEN STRATEGY_BACKEND = "JWT"
597
+ """
598
+ return g.config.get("BEARER_TOKEN_AUDIENCE")
599
+
600
+ @property
601
+ def BEARER_ALGORITHM(self):
602
+ """
603
+ ONLY WHEN STRATEGY_BACKEND = "JWT"
604
+ """
605
+ return g.config.get("BEARER_ALGORITHM")
606
+
607
+ """
608
+ --------------------------------------------------------------------------------------------------------
609
+ DEPRECATED SETTINGS
610
+ --------------------------------------------------------------------------------------------------------
611
+ """
254
612
 
255
613
  @property
256
614
  def GREMLIN_CONNECTION(self) -> tuple[str, str] | None: