|
29 | 29 |
|
30 | 30 | from celery.schedules import crontab, timedelta |
31 | 31 | from flask import request |
| 32 | +from invenio_accounts.views import rest as accounts_rest |
| 33 | +from invenio_cern_sync.sso import cern_keycloak, cern_remote_app_name, handlers |
| 34 | +from invenio_cern_sync.sso.api import confirm_registration_form |
| 35 | +from invenio_cern_sync.users.profile import CERNUserProfileSchema |
| 36 | +from invenio_oauthclient.views.client import auto_redirect_login |
32 | 37 | from invenio_records_files.api import _Record |
33 | 38 | from invenio_records_rest.config import RECORDS_REST_ENDPOINTS |
34 | 39 | from invenio_records_rest.facets import nested_filter, range_filter, terms_filter |
|
43 | 48 | from urllib3.exceptions import InsecureRequestWarning |
44 | 49 |
|
45 | 50 | from cernopendata.cold_storage.tasks import CheckTransfersTask |
46 | | -from cernopendata.modules.pages.config import * |
| 51 | + |
| 52 | +# noinspection PyUnresolvedReferences |
| 53 | +# from cernopendata.modules.pages.config import * |
| 54 | +# noinspection PyUnresolvedReferences |
| 55 | +from cernopendata.modules.releases import models |
| 56 | +from cernopendata.modules.releases.utils import ( |
| 57 | + user_info_with_cern_roles, |
| 58 | + user_payload_with_cern_roles, |
| 59 | +) |
47 | 60 | from cernopendata.modules.search_ui.helpers import CODSearchAppInvenioRestConfigHelper |
| 61 | + |
| 62 | +# noinspection PyUnresolvedReferences |
48 | 63 | from cernopendata.modules.theme.config import * |
49 | 64 | from cernopendata.tasks import ProcessEosDumpTask |
50 | 65 |
|
|
68 | 83 |
|
69 | 84 | # Piwik tracking code: set None to disabled it |
70 | 85 | THEME_PIWIK_ID = os.environ.get("PIWIK_ID", None) |
71 | | -ACCOUNTS_SESSION_ACTIVITY_ENABLED = None |
| 86 | +# ACCOUNTS_SESSION_ACTIVITY_ENABLED = True |
| 87 | +# ACCOUNTS_REGISTER = True # allow registration |
| 88 | +# ACCOUNTS_CONFIRM_EMAIL = None# require email confirmation (recommended) |
| 89 | +# ACCOUNTS_SESSION_RESTORATION = True |
| 90 | +# ACCOUNTS_REST_AUTH_VIEWS= True |
| 91 | +# SECURITY_REGISTERABLE = True |
| 92 | +# SECURITY_RECOVERABLE = True |
| 93 | +# SECURITY_CHANGEABLE = True |
| 94 | + |
| 95 | +# SECURITY_LOGIN_URL = "/login" |
| 96 | +# SECURITY_LOGOUT_URL = "/logout" |
| 97 | +# SECURITY_REGISTER_URL = "/signup" |
| 98 | + |
| 99 | +# Required for sessions |
| 100 | +SECRET_KEY = "change-me-pleaaaseeeee!!!" |
| 101 | +# SECURITY_PASSWORD_SALT = "change-me-too" |
| 102 | + |
72 | 103 | SITE_URL = os.environ.get("CERNOPENDATA_SITE_URL", "opendata.cern.ch") |
73 | 104 |
|
74 | 105 | # Logging - Set up Sentry for Invenio-Logging |
|
163 | 194 | "params": {"preprocessors": [flag_robots, anonymize_user, build_record_unique_id]}, |
164 | 195 | } |
165 | 196 |
|
166 | | - |
167 | 197 | STATS_AGGREGATIONS = { |
168 | 198 | "file-download-agg": { |
169 | 199 | "templates": "invenio_stats.contrib.aggregations.aggr_file_download", |
|
253 | 283 | }, |
254 | 284 | } |
255 | 285 |
|
256 | | - |
257 | 286 | CELERY_BEAT_SCHEDULE = { |
258 | 287 | # indexing of statistics events & aggregations |
259 | 288 | "stats-process-events": { |
|
276 | 305 | # JSONSchemas |
277 | 306 | JSONSCHEMAS_ENDPOINT = "/schema" |
278 | 307 | JSONSCHEMAS_HOST = "opendata.cern.ch" |
279 | | -JSONSCHEMAS_URL_SCHEME = "http" |
| 308 | +# JSONSCHEMAS_URL_SCHEME = "http" |
| 309 | +JSONSCHEMAS_REPLACE_REFS = True |
280 | 310 |
|
281 | 311 | # HOST_URI |
282 | | -HOST_URI = "{}://{}".format(JSONSCHEMAS_URL_SCHEME, JSONSCHEMAS_HOST) |
283 | | - |
| 312 | +# HOST_URI = "{}://{}".format(JSONSCHEMAS_URL_SCHEME, JSONSCHEMAS_HOST) |
| 313 | +# |
| 314 | +# TODO: This is a hack! There is an issue with the resolver. Setting these two things make the test fail |
| 315 | +# If we don't set them, the curation process can't validate the json schema |
| 316 | +if "CERNOPENDATA_CERN_APP_CREDENTIALS" in os.environ: |
| 317 | + RECORDS_REFRESOLVER_STORE = "invenio_jsonschemas.proxies.current_refresolver_store" |
| 318 | + RECORDS_REFRESOLVER_CLS = "invenio_records.resolver.InvenioRefResolver" |
284 | 319 | # Records |
285 | 320 | # Add tuple as array type on record validation |
286 | 321 | # http://python-jsonschema.readthedocs.org/en/latest/validate/#validating-types |
@@ -501,6 +536,15 @@ def _query_parser_and(qstr=None): |
501 | 536 | ), |
502 | 537 | } |
503 | 538 | } |
| 539 | +COVER_TEMPLATE = "invenio_theme/page_cover.html" |
| 540 | +ACCOUNTS_COVER_TEMPLATE = "invenio_accounts/base_cover.html" |
| 541 | +ACCOUNTS_BASE_TEMPLATE = "invenio_accounts/base.html" |
| 542 | +# After 'Create app' |
| 543 | +# MAIL_SERVER='smtp.example.com' |
| 544 | +# MAIL_PORT = 465 |
| 545 | +# MAIL_USE_SSL= True |
| 546 | +# MAIL_USERNAME = 'username' |
| 547 | +COMMUNITIES_IDENTITIES_CACHE_REDIS_URL = "redis://cache:6379/0" |
504 | 548 |
|
505 | 549 | # TODO: based on invenio-records-rest default config |
506 | 550 | RECORDS_REST_DEFAULT_SORT = dict( |
@@ -634,7 +678,6 @@ def _query_parser_and(qstr=None): |
634 | 678 | "invenio_records_rest": CODSearchAppInvenioRestConfigHelper, |
635 | 679 | } |
636 | 680 |
|
637 | | - |
638 | 681 | SEARCH_UI_SEARCH_VIEW = search_legacy |
639 | 682 | # OAI-PMH |
640 | 683 | # ======= |
@@ -718,3 +761,52 @@ def _query_parser_and(qstr=None): |
718 | 761 |
|
719 | 762 | # THIS ONE IS ONLY FOR THE DEVELOPMENT |
720 | 763 | RATELIMIT_PER_ENDPOINT = {"static": "600 per minute"} |
| 764 | + |
| 765 | +# Checking communities |
| 766 | +THEME_FRONTPAGE = False |
| 767 | +# Enable communities |
| 768 | +COMMUNITIES_ENABLED = True |
| 769 | + |
| 770 | +ACCOUNTS_LOCAL_LOGIN_ENABLED = False |
| 771 | +ACCOUNTS_LOGIN_VIEW_FUNCTION = auto_redirect_login |
| 772 | + |
| 773 | +ACCOUNTS_USER_PROFILE_SCHEMA = CERNUserProfileSchema() |
| 774 | + |
| 775 | +USERPROFILES_EXTEND_SECURITY_FORMS = True |
| 776 | +CERN_SYNC_KEYCLOAK_BASE_URL = "https://auth.cern.ch/" |
| 777 | + |
| 778 | +OAUTHCLIENT_SIGNUP_FORM = confirm_registration_form |
| 779 | +OAUTHCLIENT_CERN_REALM_URL = "https://auth.cern.ch/auth/realms/cern" |
| 780 | +OAUTHCLIENT_CERN_USER_INFO_URL = ( |
| 781 | + "https://auth.cern.ch/auth/realms/cern/protocol/openid-connect/userinfo" |
| 782 | +) |
| 783 | +OAUTHCLIENT_SETTINGS_TEMPLATE = "invenio_oauthclient/settings/base.html" |
| 784 | +OAUTHCLIENT_CERN_VERIFY_EXP = True |
| 785 | +OAUTHCLIENT_CERN_VERIFY_AUD = False |
| 786 | +OAUTHCLIENT_CERN_USER_INFO_FROM_ENDPOINT = True |
| 787 | +OAUTHCLIENT_CERN_OPENID_ALLOWED_ROLES = [ |
| 788 | + "cms-curator", |
| 789 | + "atlas-curator", |
| 790 | + "delphi-curator", |
| 791 | + "alice-curator", |
| 792 | + "default-role", |
| 793 | +] |
| 794 | +OAUTHCLIENT_AUTO_REDIRECT_TO_EXTERNAL_LOGIN = True |
| 795 | + |
| 796 | +OAUTH_REMOTE_APP_NAME = "cern_openid" |
| 797 | +OAUTHCLIENT_REMOTE_APPS = { |
| 798 | + cern_remote_app_name: cern_keycloak.remote_app, |
| 799 | +} |
| 800 | +CERN_APP_CREDENTIALS = { |
| 801 | + "consumer_key": "opendata-dev", |
| 802 | + "consumer_secret": os.environ.get( |
| 803 | + "CERNOPENDATA_CERN_APP_CREDENTIALS", "<CHANGEME>" |
| 804 | + ), |
| 805 | +} |
| 806 | + |
| 807 | +accounts_rest.default_user_payload = user_payload_with_cern_roles |
| 808 | +handlers["signup_handler"]["info"] = user_info_with_cern_roles |
| 809 | + |
| 810 | +# OAUTHCLIENT_SETTINGS_TEMPLATE = 'invenio_theme/page_settings.html' |
| 811 | +COMMUNITIES_CUSTOM_FIELDS = None |
| 812 | +MAX_CONTENT_LENGTH = 1000 * 1024 * 1024 |
0 commit comments