oarepo_config.generic_parameters
oarepo_config.generic_parameters
Generic configuration parameters for oarepo-config.
configure_global_logging() -> None
Configure global logging settings.
Source code in oarepo_config/generic_parameters.py
configure_generic_parameters(languages: tuple[tuple[str, str], ...] = (('en', 'English'),), use_path_pid_ids: bool = False) -> None
Set up the core, infrastructure-level configuration of the repository.
This is the main "plumbing" function that should normally be called
first, before any of the other configure_* functions. It reads
most of its values from the deployment's environment configuration
(the variables/.env files or process environment variables,
all prefixed with INVENIO_) and uses them to configure:
- the site's public URLs, and allowed security headers
- whether local login/registration/password-reset is available
- the database, search engine (OpenSearch), file storage (S3), cache and message queue (Redis/RabbitMQ) connections
- translation/locale and file-upload defaults
-
default identifier schemes recognised for names, funders and affiliations (e.g. ORCID, ROR, VEDIDK, Scopus author ID)
-
the InvenioRDM security defaults that upstream ships in
invenio_app_rdm.configand that only make sense for a deployed repository (CSRF protection, shared rate limiting, database pool options, permission cache) - see "InvenioRDM flavour defaults" below
Because most values come from the environment, this function will
fail to start the application if a required INVENIO_... variable
is missing from the deployment's configuration - see the project's
README for the full list of variables it expects.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
languages
|
tuple[tuple[str, str], ...]
|
Extra UI languages to offer, as a tuple of
|
(('en', 'English'),)
|
use_path_pid_ids
|
bool
|
Set this to |
False
|
Invenio configuration variables set, grouped by area:
Public URLs & security headers
* TRUSTED_HOSTS
* SITE_UI_URL, SITE_API_URL
* APP_DEFAULT_SECURE_HEADERS
Local login & accounts
* ACCOUNTS_LOCAL_LOGIN_ENABLED, SECURITY_REGISTERABLE,
SECURITY_RECOVERABLE, SECURITY_CHANGEABLE,
SECURITY_CONFIRMABLE,
SECURITY_LOGIN_WITHOUT_CONFIRMATION
* SESSION_COOKIE_SECURE
* RATELIMIT_GUEST_USER, RATELIMIT_AUTHENTICATED_USER
* OAUTHCLIENT_REMOTE_APPS - starts out empty here; extended
by configure_einfra_oidc if used.
* ACCOUNTS_LOGIN_VIEW_FUNCTION,
OAUTHCLIENT_AUTO_REDIRECT_TO_EXTERNAL_LOGIN
Database
* SQLALCHEMY_DATABASE_URI
Translation/locale
* BABEL_DEFAULT_LOCALE, BABEL_DEFAULT_TIMEZONE,
I18N_LANGUAGES
Files & storage
* SEND_FILE_MAX_AGE_DEFAULT, FILES_REST_STORAGE_FACTORY
* S3_ENDPOINT_URL, S3_ACCESS_KEY_ID,
S3_SECRET_ACCESS_KEY
* FILES_REST_STORAGE_CLASS_LIST,
FILES_REST_DEFAULT_STORAGE_CLASS,
FILES_REST_DEFAULT_QUOTA_SIZE
* APP_RDM_DEPOSIT_FORM_QUOTA
User profiles
* USERPROFILES_READ_ONLY
OAI-PMH
* OAISERVER_ID_PREFIX
Search (OpenSearch)
* SEARCH_INDEX_PREFIX, SEARCH_HOSTS,
SEARCH_CLIENT_CONFIG - set INVENIO_OPENSEARCH_TIMEOUT
(seconds) to raise the search request timeout.
* VOCABULARIES_SERVICE_CONFIG,
VOCABULARIES_RESOURCE_CONFIG - only if the optional
oarepo_vocabularies package is installed.
Caches (Redis)
* INVENIO_CACHE_TYPE, CACHE_REDIS_URL,
ACCOUNTS_SESSION_REDIS_URL,
COMMUNITIES_IDENTITIES_CACHE_REDIS_URL
Background jobs (Celery/RabbitMQ)
* CELERY_BROKER_URL, BROKER_URL,
CELERY_RESULT_BACKEND
JSON schemas
* RECORDS_REFRESOLVER_CLS, RECORDS_REFRESOLVER_STORE,
JSONSCHEMAS_HOST
Secrets
* SECRET_KEY
Records/REST compatibility
* DASHBOARD_RECORD_CREATE_URL, RECORD_ROUTES,
RECORDS_REST_ENDPOINTS
DataCite/DOIs
* DATACITE_TEST_MODE
Mail
* MAIL_DEFAULT_SENDER
* MAIL_SUPPRESS_SEND - only if INVENIO_MAIL_SUPPRESS_SEND
is set in the environment.
Identifier/name/funder/affiliation vocabularies
* VOCABULARIES_NAMES_SCHEMES, VOCABULARIES_FUNDER_SCHEMES,
VOCABULARIES_AFFILIATION_SCHEMES - merged with any
existing value.
* APP_RDM_IDENTIFIER_SCHEMES_UI
* VOCABULARIES_DATASTREAM_READERS,
VOCABULARIES_DATASTREAM_WRITERS,
VOCABULARIES_DATASTREAM_TRANSFORMERS - seeded from
invenio-app-rdm's defaults, merged with any existing
value; see configure_datastreams to add your own.
Miscellaneous
* ROR_CLIENT_ID, SESSION_COOKIE_DOMAIN,
COLLECT_STORAGE
InvenioRDM flavour defaults
Upstream InvenioRDM applies these through
invenio_app_rdm.config, which OARepo does not load. The inert
ones are defaults of every OARepo application (see
oarepo.initial_rdm_config and oarepo_rdm.initial_config);
the ones below switch on enforcement or depend on the
deployment, so they are applied here. Each of them can be
overridden by a plain assignment later in invenio.cfg.
* `REST_CSRF_ENABLED` - CSRF protection of the REST API for
browser-session requests (API-token requests are exempt).
* `ACCESS_CACHE` - caches resolved action permissions.
* `RATELIMIT_STORAGE_URI` - rate limiting counters shared by
all web processes in Redis instead of per-process memory.
Taken from `INVENIO_RATELIMIT_STORAGE_URI`, or built from the
Redis connection and `INVENIO_REDIS_RATELIMIT_DB` (default
`4`).
* `ACCOUNTS_LOGIN_RATELIMIT`,
`ACCOUNTS_FORGOT_PASSWORD_EMAIL_RATELIMIT`,
`ACCOUNTS_SEND_CONFIRMATION_RATELIMIT`
* `SQLALCHEMY_ENGINE_OPTIONS` - connection pool recycling and
timeout, UTC session time zone, host name as the connection's
`application_name`. `INVENIO_PGBOUNCER_ENABLED=True` disables
pooling in the application; `INVENIO_SQLALCHEMY_ENGINE_OPTIONS`
(a JSON object) is merged over the result.
* `APP_RDM_ADMIN_EMAIL_RECIPIENT` - recipient of the file
integrity report, from
`INVENIO_APP_RDM_ADMIN_EMAIL_RECIPIENT`.
In addition, if use_path_pid_ids is True, this patches the
url_prefix of RDMParentRecordLinksResourceConfig,
RDMParentGrantsResourceConfig, RDMGrantUserAccessResourceConfig
and RDMGrantGroupAccessResourceConfig directly - this is a class
attribute change, not a new invenio.cfg variable.
Example
Source code in oarepo_config/generic_parameters.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 | |