-
Notifications
You must be signed in to change notification settings - Fork 31
/
invenio.cfg
1130 lines (982 loc) · 35.6 KB
/
invenio.cfg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
"""
InvenioRDM settings for Zenodo project.
This file was automatically generated by 'invenio-cli init'.
For the full list of settings and their values, see
https://invenio-app-rdm.readthedocs.io/en/latest/configuration.html
and the config.py files of your installed modules
https://invenio.readthedocs.io/en/latest/general/bundles.html
Only configuration created via cookiecutter or very likely to be edited
by installer are included here.
"""
import os
import socket
from copy import deepcopy
from datetime import timedelta
from celery.schedules import crontab
from flask_resources import create_error_handler
from invenio_administration.permissions import administration_permission
from invenio_app_rdm.config import (
APP_RDM_DEPOSIT_FORM_DEFAULTS as DEPOSIT_FORM_DEFAULTS,
)
from invenio_app_rdm.config import (
APP_RDM_IDENTIFIER_SCHEMES_UI,
APP_RDM_ROUTES,
CELERY_BEAT_SCHEDULE,
)
from invenio_app_rdm.config import (
COMMUNITIES_ERROR_HANDLERS as BASE_COMMUNITIES_ERROR_HANDLERS,
)
from invenio_communities.communities.services import facets as community_facets
from invenio_github.oauth.remote_app import github_app as github_remote_app
from invenio_i18n import lazy_gettext as _
from invenio_oauthclient.contrib.keycloak import KeycloakSettingsHelper
from invenio_oauthclient.contrib.orcid import (
REMOTE_MEMBER_APP,
REMOTE_SANDBOX_MEMBER_APP,
)
from invenio_oauthclient.views.client import auto_redirect_login
from invenio_rdm_records.config import RDM_FACETS, RDM_RECORDS_PERSONORG_SCHEMES
from invenio_rdm_records.config import RDM_SORT_OPTIONS as BASE_SORT_OPTIONS
from invenio_rdm_records.contrib.journal import JOURNAL_SORT_OPTIONS
from invenio_rdm_records.contrib.meeting import MEETING_SORT_OPTIONS
from invenio_rdm_records.resources.config import (
error_handlers as base_records_error_handlers,
)
from invenio_rdm_records.resources.errors import HTTPJSONException
from invenio_rdm_records.services.components import DefaultRecordsComponents
from invenio_rdm_records.services.components.signal import SignalComponent
from invenio_records_resources.services.records.queryparser import (
FieldValueMapper,
QueryParser,
SearchFieldTransformer,
)
from invenio_vocabularies.services.custom_fields import (
SUBJECT_FIELDS,
SUBJECT_FIELDS_UI,
)
from zenodo_rdm import facets as zenodo_community_facets
from zenodo_rdm import providers as zenodo_providers
from zenodo_rdm.api import ZenodoRDMDraft, ZenodoRDMRecord
from zenodo_rdm.custom_fields import (
CUSTOM_FIELDS,
CUSTOM_FIELDS_FACETS,
CUSTOM_FIELDS_UI,
NAMESPACES,
)
from zenodo_rdm.custom_schemes import is_edmo
from zenodo_rdm.files import storage_factory
from zenodo_rdm.github.schemas import CitationMetadataSchema
from zenodo_rdm.legacy.resources import record_serializers
from zenodo_rdm.metrics.config import METRICS_CACHE_UPDATE_INTERVAL
from zenodo_rdm.moderation.errors import UserBlockedException
from zenodo_rdm.moderation.handlers import CommunityModerationHandler, RecordModerationHandler
from zenodo_rdm.openaire.records.components import OpenAIREComponent
from zenodo_rdm.permissions import (
ZenodoCommunityPermissionPolicy,
ZenodoRDMRecordPermissionPolicy,
)
from zenodo_rdm.queryparser import word_communities, word_doi
from zenodo_rdm.subcommunities import (
ZenodoSubCommunityRequest,
ZenodoSubcommunityRequestSchema,
ZenodoSubCommunityInvitationRequest
)
from zenodo_rdm.tokens import RATSubjectSchema
from zenodo_rdm.views import frontpage_view_function
try:
from invenio_rdm_records.resources.iiif import IIPServerProxy
except ImportError:
IIPServerProxy = None
# Flask
# =====
# See https://flask.palletsprojects.com/en/1.1.x/config/
SECRET_KEY = "CHANGE_ME"
# Since HAProxy and Nginx route all requests no matter the host header
# provided, the allowed hosts variable is set to localhost. In production it
# should be set to the correct host and it is strongly recommended to only
# route correct hosts to the application.
APP_ALLOWED_HOSTS = ["0.0.0.0", "localhost", "127.0.0.1"]
APP_RDM_ROUTES["index"] = ("/", frontpage_view_function)
ZENODO_ENV = os.environ.get("ZENODO_ENV", "production").lower()
# Flask-SQLAlchemy
# ================
# See https://flask-sqlalchemy.palletsprojects.com/en/2.x/config/
def _parse_env_bool(var_name, default=None):
if str(os.environ.get(var_name)).lower() == "true":
return True
elif str(os.environ.get(var_name)).lower() == "false":
return False
return default
SQLALCHEMY_ENGINE_OPTIONS = {
"connect_args": {"application_name": socket.gethostname()},
}
if _parse_env_bool("INVENIO_PGBOUNCER_ENABLED", False):
from sqlalchemy.pool import NullPool
SQLALCHEMY_ENGINE_OPTIONS["poolclass"] = NullPool
else:
SQLALCHEMY_DATABASE_URI = "postgresql+psycopg2://zenodo:zenodo@localhost/zenodo"
# Invenio-App
# ===========
# See https://invenio-app.readthedocs.io/en/latest/configuration.html
APP_DEFAULT_SECURE_HEADERS = {
"content_security_policy": {
"default-src": [
"'self'",
"fonts.googleapis.com", # for fonts
"*.gstatic.com", # for fonts
"data:", # for fonts
"'unsafe-inline'", # for inline scripts and styles
"'unsafe-eval'", # for webpack build
"blob:", # for pdf preview
"zenodo-broker.web.cern.ch",
"zenodo-broker-qa.web.cern.ch",
# Profiler reprot viewer dependencies
"maxcdn.bootstrapcdn.com",
"cdnjs.cloudflare.com",
"ajax.googleapis.com",
# For CERN Matomo
"webanalytics.web.cern.ch",
],
},
"content_security_policy_report_only": False,
"content_security_policy_report_uri": None,
"force_file_save": False,
"force_https": True,
"force_https_permanent": False,
"frame_options": "sameorigin",
"frame_options_allow_from": None,
"session_cookie_http_only": True,
"session_cookie_secure": True,
"strict_transport_security": True,
"strict_transport_security_include_subdomains": True,
"strict_transport_security_max_age": 31556926, # One year in seconds
"strict_transport_security_preload": False,
}
# Celery
# ======
# Remove file integrity checks
CELERY_BEAT_SCHEDULE.pop("file-integrity-report", None)
CELERY_BEAT_SCHEDULE = {
**CELERY_BEAT_SCHEDULE,
"metrics-calculate": {
"task": "zenodo_rdm.metrics.tasks.calculate_metrics",
"kwargs": {
"metric_id": "openaire-nexus",
},
"schedule": METRICS_CACHE_UPDATE_INTERVAL,
},
"sitemap-updater": {
"task": "zenodo_rdm.sitemap.tasks.update_sitemap_cache",
"schedule": timedelta(hours=24),
},
"openaire-failures-retry": {
"task": "zenodo_rdm.openaire.tasks.retry_openaire_failures",
"schedule": crontab(minute=0, hour=9), # Every day at 09:00 UTC
},
"stats-export": {
"task": "zenodo_rdm.stats.tasks.export_stats",
"schedule": crontab(minute=0, hour=4),
"kwargs": {
"retry": True,
},
},
"cleanup-swh-depositions": {
"task": "invenio_swh.tasks.cleanup_depositions",
"schedule": crontab(minute=0, hour=6), # Every day at 06:00 UTC
},
# Overriding existing file-checks
"file-checks": {
"task": "invenio_files_rest.tasks.schedule_checksum_verification",
"schedule": timedelta(hours=1),
"kwargs": {
"batch_interval": {"hours": 1},
"frequency": {"days": 180},
"max_count": 0,
"files_query": "invenio_app_rdm.utils.files.checksum_verification_files_query",
},
},
"update-collections-size": {
"task": "invenio_rdm_records.collections.tasks.update_collections_size",
"schedule": timedelta(hours=1), # Every hour
},
}
# The URI prefix for files checksum files query
FILES_REST_CHECKSUM_VERIFICATION_URI_PREFIXES = {
"root://eosmedia.cern.ch//eos/media/zenodo/prod",
}
CELERY_TASK_ROUTES = {
# Low
"invenio_files_rest.tasks.verify_checksum": {"queue": "low"},
"invenio_rdm_records.services.iiif.tasks.generate_tiles": {"queue": "low"},
"invenio_vocabularies.datastreams.tasks.write_entry": {"queue": "low"},
"invenio_vocabularies.datastreams.tasks.write_many_entry": {"queue": "low"},
"zenodo_rdm.openaire.tasks.openaire_delete": {"queue": "low"},
# Spam
"invenio_users_resources.services.users.tasks.execute_moderation_actions": {
"queue": "spam"
},
"invenio_rdm_records.requests.user_moderation.tasks.delete_record": {
"queue": "spam"
},
"invenio_rdm_records.requests.user_moderation.tasks.restore_record": {
"queue": "spam"
},
"invenio_communities.requests.user_moderation.tasks.delete_community": {
"queue": "spam"
},
"invenio_communities.requests.user_moderation.tasks.restore_community": {
"queue": "spam"
},
"zenodo_rdm.moderation.tasks.run_moderation_handlers": {"queue": "spam"},
"zenodo_rdm.moderation.tasks.update_moderation_request": {"queue": "spam"},
}
# Flask-Babel
# ===========
# See https://flask-babel.tkte.ch/#configuration
# Default locale (language)
BABEL_DEFAULT_LOCALE = "en"
# Default time zone
BABEL_DEFAULT_TIMEZONE = "Europe/Zurich"
# Invenio-I18N
# ============
# See https://invenio-i18n.readthedocs.io/en/latest/configuration.html
BABEL_DEFAULT_LOCALE = "en"
# Other supported languages (do not include BABEL_DEFAULT_LOCALE in list).
I18N_LANGUAGES = []
# Invenio-Theme
# =============
# See https://invenio-theme.readthedocs.io/en/latest/configuration.html
# Frontpage title
THEME_FRONTPAGE_TITLE = "Zenodo"
# Header logo
THEME_LOGO = "images/invenio-rdm.svg"
THEME_SITENAME = "Zenodo"
# Templates
THEME_FRONTPAGE_TEMPLATE = "zenodo_rdm/frontpage.html"
THEME_FOOTER_TEMPLATE = "zenodo_rdm/footer.html"
# Site tracking code template for matomo analytics
# Enable the below on the dedicated environment
# THEME_TRACKINGCODE_TEMPLATE = "zenodo_rdm/trackingcode/trackingcode-qa.html"
COOKIE_POLICY_URL = "https://about.zenodo.org/cookie-policy"
# Invenio-App-RDM
# ===============
# See https://invenio-app-rdm.readthedocs.io/en/latest/configuration.html
# Set default file quuota to 50GB
APP_RDM_DEPOSIT_FORM_QUOTA = {
"maxFiles": 100,
"maxStorage": 5 * 10**10,
}
# Instance's theme entrypoint file. Path relative to the ``assets/`` folder.
INSTANCE_THEME_FILE = "./less/theme.less"
# For invenio-vocabularies
# Silent warnings
JSONSCHEMAS_HOST = "unused"
# Invenio-RDM-Records
# ===================
# See https://github.com/inveniosoftware/invenio-rdm-records/blob/master/invenio_rdm_records/config.py
DATACITE_ENABLED = True
DATACITE_PREFIX = "10.5281"
DATACITE_FORMAT = "{prefix}/zenodo.{id}"
DATACITE_TEST_MODE = True
DATACITE_DATACENTER_SYMBOL = "CERN.ZENODO"
OAISERVER_ID_PREFIX = "zenodo.org"
OAISERVER_ADMIN_EMAILS = ["[email protected]"]
RDM_ALLOW_METADATA_ONLY_RECORDS = False
RDM_ALLOW_RESTRICTED_RECORDS = False
RDM_ALLOW_EXTERNAL_DOI_VERSIONING = False
RDM_PERMISSION_POLICY = ZenodoRDMRecordPermissionPolicy
# Override record and draft API classes
RDM_RECORD_CLS = ZenodoRDMRecord
RDM_DRAFT_CLS = ZenodoRDMDraft
RDM_RECORDS_SERIALIZERS = record_serializers
records_block_message = (
"Your account has been blocked - the record you tried to publish has been "
"classified as spam by our automated spam protection system. Your account has "
"therefore been blocked and the record has not been published. If you believe this "
"is a mistake, please contact us on our support line."
)
RDM_RECORDS_ERROR_HANDLERS = {
**base_records_error_handlers,
UserBlockedException: create_error_handler(
lambda _: HTTPJSONException(code=400, description=records_block_message)
),
}
RDM_PARENT_PERSISTENT_IDENTIFIER_PROVIDERS = (
zenodo_providers.RDM_PARENT_PERSISTENT_IDENTIFIER_PROVIDERS
)
RDM_PARENT_PERSISTENT_IDENTIFIERS = zenodo_providers.RDM_PARENT_PERSISTENT_IDENTIFIERS
RDM_RESOURCE_ACCESS_TOKENS_ENABLED = True
RDM_RESOURCE_ACCESS_TOKEN_REQUEST_ARG = "resource-token"
RDM_RESOURCE_ACCESS_TOKENS_SUBJECT_SCHEMA = RATSubjectSchema
# Invenio-Search
# ==============
SEARCH_INDEX_PREFIX = "zenodo-"
INDEXER_MQ_PUBLISH_KWARGS = {
"retry": True,
"retry_policy": { # Setting for maximum waiting time of ~10min:
"interval_start": 0, # First retry immediately,
"interval_step": 2, # then increase by 2s for every retry.
"interval_max": 30, # but don't exceed 30s between retries.
"max_retries": 20, # give up after 30 tries.
},
}
ZENODO_LEGACY_SEARCH_MAP = {
"resource_type.subtype": "metadata.resource_type.props.subtype",
"resource_type.type": "metadata.resource_type.props.type",
"access_right": "access.status",
"alternate.identifier": "metadata.identifiers.identifier",
"alternate.scheme": "metadata.identifiers.scheme",
"communities": FieldValueMapper("parent.communities.ids", word=word_communities),
"conceptdoi": FieldValueMapper("parent.pids.doi.identifier", word=word_doi),
"conceptrecid": "parent.id",
"created": "created",
# Creators
"creators.affiliation": "metadata.creators.affiliations.name",
"creators.name": "metadata.creators.person_or_org.name",
"creators.orcid": "metadata.creators.person_or_org.identifiers.identifier",
"creators.gnd": "metadata.creators.person_or_org.identifiers.identifier",
# Contributors
"contributors.affiliation": "metadata.contributors.affiliations.name",
"contributors.name": "metadata.contributors.person_or_org.name",
"contributors.orcid": "metadata.contributors.person_or_org.identifiers.identifier",
"contributors.gnd": "metadata.contributors.person_or_org.identifiers.identifier",
"contributors.type": "metadata.contributors.role.id",
"description": "metadata.description",
"doi": FieldValueMapper("pids.doi.identifier", word=word_doi),
"embargodate": "access.embargo.until",
"grants.code": "metadata.funding.award.number",
"grants.acronym": "metadata.funding.award.acronym",
"grants.program": "metadata.funding.award.program",
"grants.title": "metadata.funding.award.title.en",
# owner
"owners": "parent.access.owned_by.user",
# TODO: Add `grants.funder.*` mappings
"grants.funder.doi": FieldValueMapper(
"metadata.funding.funder.identifiers.identifier", word=word_doi
),
"grants.funder.name": "metadata.funding.funder.name",
"keywords": "metadata.subjects.subject",
"language": "metadata.languages.id",
"license.identifier": "metadata.rights.id",
"license.url": "metadata.rights.props.url",
"publicationdate": "metadata.publication_date",
"publication_date": "metadata.publication_date",
"recid": "id",
"related.identifier": "metadata.related_identifiers.identifier",
"related.scheme": "metadata.related_identifiers.scheme",
"related.relation": "metadata.related_identifiers.relation_type.id",
"title": "metadata.title",
"type": "metadata.resource_type.props.type",
"version": "versions.index",
# journal custom field mappings
"journal.title": "custom_fields.journal\:journal.title",
"journal.pages": "custom_fields.journal\:journal.pages",
"journal.volume": "custom_fields.journal\:journal.volume",
"journal.issn": "custom_fields.journal\:journal.issn",
# meeting custom field mappings
"meeting.title": "custom_fields.meeting\:meeting.title",
"meeting.acronym": "custom_fields.meeting\:meeting.acronym",
"meeting.dates": "custom_fields.meeting\:meeting.dates",
"meeting.place": "custom_fields.meeting\:meeting.place",
"meeting.url": "custom_fields.meeting\:meeting.url",
"meeting.session": "custom_fields.meeting\:meeting.session",
"meeting.session_part": "custom_fields.meeting\:meeting.session_part",
"part_of.title": "custom_fields.imprint\:imprint.title",
"part_of.pages": "custom_fields.imprint\:imprint.pages",
# imprint custom field mappings
"imprint.isbn": "custom_fields.imprint\:imprint.isbn",
"imprint.place": "custom_fields.imprint\:imprint.place",
"imprint.publisher": "custom_fields.imprint\:imprint.publisher",
# notes custom field mappings
"notes": "metadata.additional_descriptions.description",
# thesis custom field mappings
"thesis.university": "custom_fields.thesis\:university",
# Files
"filecount": "files.count",
"filename": "files.entries.key",
"filetype": "files.types",
"filesize": "files.totalbytes",
"size": "files.totalbytes",
"_files.checksum": "files.entries.checksum",
"_files.size": "files.entries.size",
# New mappings
"user": "parent.access.owned_by.user",
}
LEGACY_SORT_OPTIONS = {
"-bestmatch": dict(
title=_("Best match [Least relevant]"),
fields=["-_score"],
),
"publication_date": {
"title": _("Publication date [Newest]"),
"fields": ["-metadata.publication_date", "-created"],
},
"-publication_date": {
"title": _("Publication date [Oldest]"),
"fields": ["metadata.publication_date", "created"],
},
"mostrecent": {
"title": _("Newest"),
"fields": ["-created"],
},
"-mostrecent": {
"title": _("Oldest"),
"fields": ["created"],
},
"-mostviewed": dict(
title=_("Most viewed [Least views first]"),
fields=["stats.all_versions.unique_views"],
),
"journal": {
"title": _("Journal [Newest]"),
"fields": [
"-metadata.publication_date",
"custom_fields.journal:journal.volume",
"custom_fields.journal:journal.issue",
"custom_fields.journal:journal.pages",
],
},
"-journal": {
"title": _("Journal [Oldest]"),
"fields": [
"metadata.publication_date",
"custom_fields.journal:journal.volume",
"custom_fields.journal:journal.issue",
"custom_fields.journal:journal.pages",
],
},
"conference_session": {
"title": _("Conference session [Newest]"),
"fields": [
"-custom_fields.meeting:meeting.session",
"-custom_fields.meeting:meeting.session_part",
],
},
"-conference_session": {
"title": _("Conference session [Oldest]"),
"fields": [
"custom_fields.meeting:meeting.session",
"custom_fields.meeting:meeting.session_part",
],
},
"-version": dict(
title=_("Version [Oldest]"),
fields=["versions.index"],
),
}
RDM_SORT_OPTIONS = {
# base brings bestmatch, newest, oldest, updated-desc, updated-asc, versions
# FIXME: there is no conceptrecid for versions, use parent id?
**BASE_SORT_OPTIONS,
"publication-desc": {
"title": _("Published [Newest]"),
"fields": ["-metadata.publication_date", "-created"],
},
"publication-asc": {
"title": ("Published [Oldest]"),
"fields": ["metadata.publication_date", "created"],
},
**MEETING_SORT_OPTIONS, # conference asc and desc
**JOURNAL_SORT_OPTIONS, # journal asc and desc
**LEGACY_SORT_OPTIONS, # legacy sort options available only in REST API
}
RDM_SEARCH = {
"facets": ["access_status", "resource_type", "subject", "file_type"]
+ list(CUSTOM_FIELDS_FACETS.keys()),
"sort": [
"mostviewed",
"bestmatch",
"newest",
"oldest",
"version",
"publication-desc",
"publication-asc",
"conference-desc",
"journal-desc",
],
"query_parser_cls": QueryParser.factory(
mapping=ZENODO_LEGACY_SEARCH_MAP,
tree_transformer_cls=SearchFieldTransformer,
),
"sort_default_no_query": "newest",
"sort_default": "bestmatch",
}
COMMUNITIES_RECORDS_SEARCH = deepcopy(RDM_SEARCH)
"""Communities record search config is the same as the main record search."""
ZENODO_COMMUNITIES_FACETS = {
"type": {
"facet": community_facets.type,
"ui": {
"field": "type",
},
},
"funder": {
"facet": zenodo_community_facets.funder,
"ui": {
"field": "metadata.funding.funder",
},
},
"organization": {
"facet": zenodo_community_facets.organization,
"ui": {
"field": "metadata.organizations",
},
},
}
COMMUNITIES_FACETS = {
**ZENODO_COMMUNITIES_FACETS,
}
communities_block_message = (
"Your account has been blocked - your community has been classified as spam by our "
"automated spam protection system. Your account has therefore been blocked. If you "
"believe this is a mistake, please contact us on our support line."
)
COMMUNITIES_ERROR_HANDLERS = {
**BASE_COMMUNITIES_ERROR_HANDLERS,
UserBlockedException: create_error_handler(
lambda _: HTTPJSONException(code=400, description=communities_block_message)
),
}
ZENODO_COMMUNITIES_SUBCOMMUNITIES_FACETS = ZENODO_COMMUNITIES_FACETS
COMMUNITIES_SUBCOMMUNITIES_FACETS = {
**ZENODO_COMMUNITIES_SUBCOMMUNITIES_FACETS,
}
COMMUNITIES_SEARCH = {
"facets": ["type", "funder", "organization"],
"sort": ["bestmatch", "newest", "oldest"],
}
COMMUNITIES_SUBCOMMUNITIES_SEARCH = {
"facets": ["funder", "organization"],
"sort": ["bestmatch", "newest", "oldest"],
}
RDM_SEARCH_USER_COMMUNITIES = {
"facets": ["type", "funder", "organization"],
"sort": ["bestmatch", "newest", "oldest"],
}
RDM_FACETS = {**RDM_FACETS, **CUSTOM_FIELDS_FACETS}
RDM_SEARCH_DRAFTS = {
**RDM_SEARCH,
"sort_default_no_query": "newest",
"sort_default": "bestmatch",
}
# User moderation feature enabled
RDM_USER_MODERATION_ENABLED = True
# Invenio-Accounts
# ================
# See https://github.com/inveniosoftware/invenio-accounts/blob/master/invenio_accounts/config.py
ACCOUNTS_LOCAL_LOGIN_ENABLED = True # enable local login
ACCOUNTS_DEFAULT_USER_VISIBILITY = "public"
SECURITY_REGISTERABLE = True # local login: allow users to register
SECURITY_RECOVERABLE = True # local login: allow users to reset the password
SECURITY_CHANGEABLE = True # local login: allow users to change psw
SECURITY_CONFIRMABLE = True # local login: users can confirm e-mail address
SECURITY_LOGIN_WITHOUT_CONFIRMATION = (
False # don't allow users to login without confirming
)
SECURITY_EMAIL_SUBJECT_REGISTER = "Welcome to Zenodo!"
PERMANENT_SESSION_LIFETIME = timedelta(days=10)
# Invenio-OAuthclient
# ===================
_openaire_helper = KeycloakSettingsHelper(
title="OpenAIRE",
description="Open Science Services.",
base_url="https://aai.openaire.eu"
if ZENODO_ENV == "production"
else "https://beta.aai.openaire.eu",
realm="openaire",
scopes="openid profile email eduperson_entitlement orcid",
app_key="OPENAIRE_APP_CREDENTIALS",
signup_options={
"auto_confirm": False,
"send_register_msg": True,
},
)
OAUTHCLIENT_OPENAIRE_AAI_VERIFY_EXP = True
OAUTHCLIENT_OPENAIRE_AAI_VERIFY_AUD = True
OAUTHCLIENT_OPENAIRE_AAI_USER_INFO_FROM_ENDPOINT = True
OAUTHCLIENT_OPENAIRE_AAI_REALM_URL = "https://aai.openaire.eu/auth/realms/openaire"
OAUTHCLIENT_OPENAIRE_AAI_USER_INFO_URL = (
"https://aai.openaire.eu/auth/realms/openaire/protocol/openid-connect/userinfo"
)
if ZENODO_ENV == "production":
OAUTHCLIENT_REMOTE_APPS = {
"orcid": REMOTE_MEMBER_APP,
"github": github_remote_app,
"openaire_aai": _openaire_helper.remote_app,
}
OAUTHCLIENT_REST_REMOTE_APPS = {
"github": github_remote_app,
}
else:
OAUTHCLIENT_REMOTE_APPS = {
"orcid": REMOTE_SANDBOX_MEMBER_APP,
"github": github_remote_app,
"openaire_aai": _openaire_helper.remote_app,
}
OAUTHCLIENT_REST_REMOTE_APPS = {
"github": github_remote_app,
}
# secrets will be injected on deployment
ORCID_APP_CREDENTIALS = {
"consumer_key": "CHANGE ME",
"consumer_secret": "CHANGE ME",
}
OPENAIRE_APP_CREDENTIALS = {
"consumer_key": "CHANGE ME",
"consumer_secret": "CHANGE ME",
}
GITHUB_APP_CREDENTIALS = {
"consumer_key": "CHANGE ME",
"consumer_secret": "CHANGE ME",
}
# OpenAIRE API configs
OPENAIRE_API_CREDENTIALS = {"username": "CHANGE ME", "password": "CHANGE ME"}
"""API credentials."""
ACCOUNTS_LOGIN_VIEW_FUNCTION = (
auto_redirect_login # autoredirect to external login if enabled
)
OAUTHCLIENT_AUTO_REDIRECT_TO_EXTERNAL_LOGIN = False # autoredirect to external login
# Inenio-OAuth2Server
# ===================
OAUTH2_PROVIDER_TOKEN_EXPIRES_IN = 60 * 24 * 60 * 60 # 60 days
# Invenio-GitHub
# ==============
GITHUB_INTEGRATION_ENABLED = True
GITHUB_WEBHOOK_RECEIVER_ID = "github"
GITHUB_WEBHOOK_RECEIVER_URL = "CHANGE ME"
GITHUB_SHARED_SECRET = "CHANGE ME"
GITHUB_INSECURE_SSL = False
GITHUB_RELEASE_CLASS = "zenodo_rdm.github.release:ZenodoGithubRelease"
GITHUB_CITATION_METADATA_SCHEMA = CitationMetadataSchema
GITHUB_CITATION_FILE = "CITATION.cff"
# Invenio-UserProfiles
# --------------------
USERPROFILES_READ_ONLY = (
False # allow users to change profile info (name, email, etc...)
)
THEME_SHOW_FRONTPAGE_INTRO_SECTION = False
APP_RDM_RECORD_LANDING_PAGE_TEMPLATE = "zenodo_rdm/records/detail.html"
from zenodo_rdm.utils import (
annostor_link_render,
blr_link_render,
briefideas_link_render,
f1000_link_render,
github_link_render,
openaire_link_render,
reana_link_render,
swh_link_render,
)
APP_RDM_RECORD_LANDING_PAGE_EXTERNAL_LINKS = [
{"id": "f1000", "render": f1000_link_render},
{"id": "reana", "render": reana_link_render},
{"id": "github", "render": github_link_render},
{"id": "briefideas", "render": briefideas_link_render},
{"id": "openaire", "render": openaire_link_render},
{"id": "softwareheritage", "render": swh_link_render},
{"id": "blr", "render": blr_link_render},
{"id": "annostor", "render": annostor_link_render},
]
APP_RDM_DEPOSIT_FORM_DEFAULTS = {
**DEPOSIT_FORM_DEFAULTS,
"publisher": "Zenodo",
}
"""Default values for new records in the deposit UI."""
# Invenio-Base
# ============
BLUEPRINTS_URL_PREFIXES = {
# We want to override the legacy files endpoints with our own resource/service
"invenio_files_rest": "/legacy-files",
}
# Profiler
# ========
PROFILER_PERMISSION = lambda: administration_permission.can()
# Custom Fields
# =============
RDM_NAMESPACES = NAMESPACES
RDM_CUSTOM_FIELDS = CUSTOM_FIELDS
RDM_CUSTOM_FIELDS_UI = CUSTOM_FIELDS_UI # UI components
COMMUNITIES_CUSTOM_FIELDS_UI = SUBJECT_FIELDS_UI
COMMUNITIES_CUSTOM_FIELDS = SUBJECT_FIELDS
# Invenio-Communities
# ==============
COMMUNITIES_ALLOW_RESTRICTED = False
COMMUNITIES_OAI_SETS_PREFIX = "user-"
COMMUNITIES_PERMISSION_POLICY = ZenodoCommunityPermissionPolicy
COMMUNITIES_SEARCH_SORT_BY_VERIFIED = True
"""Enable the sorting of communities by verified."""
# Citations
# ==============
ZENODO_RECORDS_UI_CITATIONS_ENABLE = True
METRICS_UPTIME_ROBOT_METRIC_IDS = {}
METRICS_UPTIME_ROBOT_URL = "https://api.uptimerobot.com/v2/getMonitors"
METRICS_UPTIME_ROBOT_API_KEY = None
# Other configs
RDM_RECORDS_SERVICE_COMPONENTS = DefaultRecordsComponents + [
OpenAIREComponent,
SignalComponent,
]
"""Addd OpenAIRE component to records service."""
RDM_CONTENT_MODERATION_HANDLERS = [
RecordModerationHandler(),
]
"""Records content moderation handlers."""
RDM_COMMUNITY_CONTENT_MODERATION_HANDLERS = [
CommunityModerationHandler(),
]
"""Community content moderation handlers."""
RDM_SEARCH_SORT_BY_VERIFIED = True
"""Enable the sorting of records by verified."""
USERS_RESOURCES_ADMINISTRATION_ENABLED = True
"""Enable user administration."""
USERS_RESOURCES_GROUPS_ENABLED = False
"""Config to enable features related to existence of groups."""
COMMUNITIES_ADMINISTRATION_DISABLED = False
"""Enable communities administration."""
MAIL_DEFAULT_SENDER = "Zenodo <[email protected]>"
"""Default e-mail address sender."""
REST_ENABLE_CORS = True
"""Enable CORS validation."""
REST_CSRF_ENABLED = True
"""Enable CSRF."""
# Invenio logging
LOGGING_SENTRY_INIT_KWARGS = {
# instuct sentry to send user data attached to the event
"send_default_pii": True
}
THEME_TWITTERHANDLE = "@zenodo_org"
"""Twitter handle."""
# Invenio-Files-REST
# ==================
XROOTD_ENABLED = False
# control file download offloading
FILES_REST_STORAGE_FACTORY = storage_factory
FILES_REST_XSENDFILE_ENABLED = False
ZENODO_EOS_OFFLOAD_ENABLED = False
ZENODO_EOS_OFFLOAD_HTTPHOST = ""
ZENODO_EOS_OFFLOAD_REDIRECT_BASE_PATH = ""
# control EOS offload authentication
ZENODO_EOS_OFFLOAD_AUTH_X509 = False
"""Specifies whether to use X509 authentication for EOS offload."""
ZENODO_EOS_OFFLOAD_X509_CERT_PATH = ""
"""The path to the X509 certificate file."""
ZENODO_EOS_OFFLOAD_X509_KEY_PATH = ""
"""The path to the X509 private key file."""
# TODO: Remove once https://github.com/inveniosoftware/invenio-rdm-records/pull/1789 is merged
FILES_REST_DEFAULT_QUOTA_SIZE = 5 * 10**10
FILES_REST_DEFAULT_MAX_FILE_SIZE = 5 * 10**10
RDM_FILES_DEFAULT_QUOTA_SIZE = 50 * 10**9 # 50GB
RDM_FILES_DEFAULT_MAX_FILE_SIZE = 50 * 10**9 # 50GB
RDM_MEDIA_FILES_DEFAULT_QUOTA_SIZE = 5 * 10**9
RDM_MEDIA_FILES_DEFAULT_MAX_FILE_SIZE = 5 * 10**9
RDM_RECORDS_MAX_MEDIA_FILES_COUNT = 1000
"""Max amount of media files allowed to upload in the deposit form."""
# Rate limiting
RATELIMIT_PER_ENDPOINT = {
# Badges
"invenio_formatter_badges.badge": "120 per minute",
"invenio_github_badge.index": "120 per minute",
"invenio_github_badge.index_old": "120 per minute",
"invenio_github_badge.latest_doi": "120 per minute",
"invenio_github_badge.latest_doi_old": "120 per minute",
# Support
"zenodo_rdm.support_form": "10 per second",
# Login and registration
"security.login": "10 per minute",
"security.register": "10 per minute",
"security.forgot_password": "10 per minute",
"security.reset_password": "10 per minute",
# Front page
"invenio_app_rdm.frontpage_view_function": "10 per second",
# Records
"invenio_app_rdm_records.record_thumbnail": "20 per second",
# OAI-PMH
"invenio_oaiserver.response": "120 per minute",
# 'zenodo_redirector.contact': '10 per second',
# TODO most similar view found was: invenio_redirector.redirect_contact
}
"""Rate limits per endpoint."""
RATELIMIT_GUEST_USER = "8000 per hour;133 per minute"
"""Rate limits for guest users."""
OAISERVER_RESUMPTION_TOKEN_EXPIRE_TIME = 1 * 120
OAISERVER_PAGE_SIZE = 100
OAISERVER_XSL_URL = "/static/oai2.xsl"
RDM_DATACITE_FUNDER_IDENTIFIERS_PRIORITY = ("doi", "ror", "grid", "isni", "gnd")
"""Priority of funder identifiers types for Datacite serialization, prioritize DOI."""
RDM_RECORDS_PERSONORG_SCHEMES = {
**RDM_RECORDS_PERSONORG_SCHEMES,
"edmo": {"label": _("EDMO"), "validator": is_edmo, "datacite": "URL"},
}
"""Person and Organization Schemes."""
APP_RDM_IDENTIFIER_SCHEMES_UI = {
**APP_RDM_IDENTIFIER_SCHEMES_UI,
"edmo": {
"url_prefix": "https://edmo.seadatanet.org/report/",
"icon": "images/edmo-icon.svg",
"label": "EDMO",
},
}
"""Identifier Schemes UI config."""
RECORDS_RESOURCES_ALLOW_EMPTY_FILES = False
"""Disable empty files for Zenodo."""
IIIF_PROXY_CLASS = IIPServerProxy
"""IIIF proxy class for IIIF server."""
# Only used for proxying requests to the IIP server Docker container
RDM_IIIF_SERVER_URL = "http://127.0.0.1:8080"
"""IIIF image server URL."""
IIIF_TILES_VALID_EXTENSIONS = [
"jp2",
"jpeg",
"jpg",
"pdf",
"png",
"png",
"tif",
"tiff",
]
"""Valid extensions for IIIF tiles generation."""
IIIF_TILES_GENERATION_ENABLED = True
"""Enable IIIF tiles generation."""
IIIF_TILES_STORAGE_BASE_PATH = "images/" # relative to the instance path
"""IIIF tiles storage path."""
# Invenio-Previewer
# =================
# See https://github.com/inveniosoftware/invenio-previewer/blob/master/invenio_previewer/config.py # noqa
PREVIEWER_PREFERENCE = [
"csv_papaparsejs",
"pdfjs",
"image_previewer",
"json_prismjs",
"xml_prismjs",
"mistune",
"video_videojs",
"audio_videojs",
"ipynb",
"zip",
"txt",
]
"""Preferred previewers."""
PREVIEWER_MAX_IMAGE_SIZE_BYTES = 15 * (10**6) # 15 MB
"""Maximum file size in bytes for image files."""
PREVIEWER_IMAGE_FAILED_PROCESSING_TIMEDELTA = {
"hours": 1,
}
"""Threshold time for image processing time for failed images."""
MIRADOR_PREVIEW_EXTENSIONS = [
"pdf",
"png",
"jp2",