Skip to content

Commit

Permalink
Merge branch 'master' into Horizen-Frontpage
Browse files Browse the repository at this point in the history
  • Loading branch information
slint authored Feb 16, 2024
2 parents 24fda1e + a5bfa4e commit 01ea299
Show file tree
Hide file tree
Showing 7 changed files with 136 additions and 70 deletions.
60 changes: 37 additions & 23 deletions invenio.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ from invenio_administration.permissions import administration_permission
from invenio_app_rdm.config import CELERY_BEAT_SCHEDULE, APP_RDM_ROUTES, APP_RDM_DEPOSIT_FORM_DEFAULTS as DEPOSIT_FORM_DEFAULTS
from invenio_i18n import lazy_gettext as _
from invenio_oauthclient.contrib.keycloak import KeycloakSettingsHelper
from invenio_oauthclient.contrib.orcid import ORCIDOAuthSettingsHelper
from invenio_oauthclient.contrib.orcid import REMOTE_MEMBER_APP, REMOTE_SANDBOX_MEMBER_APP
from invenio_github.oauth.remote_app import github_app as github_remote_app
from invenio_records_resources.services.records.queryparser import FieldValueMapper
from invenio_rdm_records.config import (
Expand Down Expand Up @@ -70,6 +70,9 @@ 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/
Expand Down Expand Up @@ -347,11 +350,11 @@ LEGACY_SORT_OPTIONS = {
),
"publication_date": {
"title": _("Publication date [Newest]"),
"fields": ["-metadata.publication_date"],
"fields": ["-metadata.publication_date", "-created"],
},
"-publication_date": {
"title": _("Publication date [Oldest]"),
"fields": ["metadata.publication_date"],
"fields": ["metadata.publication_date", "created"],
},
"mostrecent": {
"title": _("Newest"),
Expand Down Expand Up @@ -408,11 +411,11 @@ RDM_SORT_OPTIONS = {
**BASE_SORT_OPTIONS,
"publication-desc": {
"title": _("Published [Newest]"),
"fields": ["-metadata.publication_date"],
"fields": ["-metadata.publication_date", "-created"],
},
"publication-asc": {
"title": ("Published [Oldest]"),
"fields": ["metadata.publication_date"],
"fields": ["metadata.publication_date", "created"],
},
**MEETING_SORT_OPTIONS, # conference asc and desc
**JOURNAL_SORT_OPTIONS, # journal asc and desc
Expand Down Expand Up @@ -507,19 +510,10 @@ PERMANENT_SESSION_LIFETIME = timedelta(days=10)

# Invenio-OAuthclient
# ===================
_orcid_helper = ORCIDOAuthSettingsHelper(
title="ORCID",
description="ORCID - Connecting Research and Researchers.",
base_url='https://api.orcid.org/',
access_token_url='https://api.orcid.org/oauth/token',
authorize_url='https://orcid.org/oauth/authorize',
)

# Openaire sandbox
_openaire_helper = KeycloakSettingsHelper(
title="OpenAIRE",
description="Open Science Services.",
base_url="https://aai.openaire.eu",
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",
Expand All @@ -529,21 +523,33 @@ _openaire_helper = KeycloakSettingsHelper(
}
)


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"


OAUTHCLIENT_REMOTE_APPS = {
"orcid": _orcid_helper.remote_app,
"github": github_remote_app,
"openaire_aai": _openaire_helper.remote_app,
}
OAUTHCLIENT_REST_REMOTE_APPS = {
"github": github_remote_app,
}
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 = {
Expand Down Expand Up @@ -712,6 +718,14 @@ 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."""


FILES_REST_DEFAULT_QUOTA_SIZE = 5*10**10
FILES_REST_DEFAULT_MAX_FILE_SIZE = 5*10**10
Expand Down
23 changes: 20 additions & 3 deletions site/zenodo_rdm/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,32 @@
class EOSFilesOffload(BaseFileStorage):
"""Offload file downloads to another server."""

def _get_auth_session(self):
"""Get a requests session with authentication configured.
If X.509 is enabled, it will be used, otherwise kerberos will be used.
"""
s = requests.Session()
x509_enabled = current_app.config.get("ZENODO_EOS_OFFLOAD_AUTH_X509", False)
cert = current_app.config.get("ZENODO_EOS_OFFLOAD_X509_CERT_PATH")
key = current_app.config.get("ZENODO_EOS_OFFLOAD_X509_KEY_PATH")
if x509_enabled and cert and key:
s.cert = (cert, key)
s.verify = False
else:
# Default to kerberos
s.auth = HTTPKerberosAuth(DISABLED)
s.verify = False
return s

def _get_eos_redirect_path(self):
"""Get the real path of the file streamed from another server."""
host = current_app.config["ZENODO_EOS_OFFLOAD_HTTPHOST"]
redirect_base_path = current_app.config["ZENODO_EOS_OFFLOAD_REDIRECT_BASE_PATH"]
base_path = urlsplit(self.fileurl).path
eos_resp = requests.get(
session = self._get_auth_session()
eos_resp = session.get(
f"{host}/{base_path}",
auth=HTTPKerberosAuth(DISABLED),
verify=False,
allow_redirects=False,
)
if eos_resp.status_code != 307:
Expand Down
37 changes: 37 additions & 0 deletions templates/semantic-ui/zenodo_rdm/macros/communities_list.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{#
# This file is part of Zenodo.
# Copyright (C) 2024 CERN.
#
# Zenodo is free software; you can redistribute it
# and/or modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of the
# License, or (at your option) any later version.
#
# Zenodo is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Zenodo; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA 02111-1307, USA.
#
# In applying this license, CERN does not
# waive the privileges and immunities granted to it by virtue of its status
# as an Intergovernmental Organization or submit itself to any jurisdiction.
-#}

{% macro communities_list(communities=None) %}
{% for community in communities %}
{% set community_title = community.metadata.get("title", "No title") if community.metadata %}
<span class="display-inline-flex comma-separated">
<a
href="/communities/{{ community.slug }}"
title="{{ community_title }}: {{_('Search')}}"
>
{{ community_title }}
</a>
</span>
{% endfor%}
{% endmacro %}
9 changes: 8 additions & 1 deletion templates/semantic-ui/zenodo_rdm/macros/record_item.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
-#}

{% from "zenodo_rdm/macros/creators.html" import creators %}
{% from "zenodo_rdm/macros/communities_list.html" import communities_list %}

{% macro record_item(record=None) %}
<li class="item">
Expand Down Expand Up @@ -62,11 +63,17 @@

{# Description #}
<p class="description">
{% set description = record.ui.get("description_stripped", "No description") %}
{% set description = record.ui.get("description_stripped", "") %}

{{ description | truncate(length=350, end='...') }}
</p>

{# Communities list #}
<h5>
{% set communities_entries = record.parent.communities.entries %}
<b>{{ _("Part of:")}} {{ communities_list(communities=communities_entries) }}</b>
</h5>

<div class="extra">
<div class="flex justify-space-between align-items-end">
{# Publishing details #}
Expand Down
15 changes: 1 addition & 14 deletions templates/themes/horizon/invenio_app_rdm/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,7 @@ <h2 class="ui small header">{{ _("Contact") }}</h2>
<div class="ui grid">
<div class="three wide five wide tablet column">
<h2 class="ui small header">{{ _("About") }}</h2>
<p><a href="{{ horizon_url }}">How it works?</a></p>
<p><a href="{{ horizon_url }}">FAQ</a></p>
<p><a href="https://about.zenodo.org/contact">Contact</a></p>
</div>
<div class="three wide computer five wide tablet column">
<h2 class="ui small header">{{ _("FAIR publishing") }}</h2>
<p><a href="{{ horizon_url }}">Getting started </a></p>
<p><a href="{{community.slug}}/upload">Submit your research</a></p>
</div>
<div class="three wide computer five wide tablet column">
<h2 class="ui small header">{{ _("Integrations") }}</h2>
<p><a href="https://developers.zenodo.org/">REST API</a></p>
<p><a href="https://developers.zenodo.org/#oai-pmh/">OAI-PMH</a></p>
<p><a href="{{ horizon_url }}">FAIR Evaluation tools</a></p>
<p><a href="https://open-research-europe.ec.europa.eu/">Learn more</a></p>
</div>
</div>
</div>
Expand Down
37 changes: 21 additions & 16 deletions templates/themes/horizon/invenio_communities/details/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,22 @@
</div>

<div class="mobile only">
<h1 class="ui medium header mb-5">
{{ community.metadata.title }}
</h1>
<a class="remove-default-style" href="{{ community.links.self_html }}">
<h1 class="ui medium header mb-5">
{{ community.metadata.title }}
</h1>
</a>
</div>
</div>

<div>
<div class="flex align-items-center mb-5 tablet computer only">
<h1 class="ui medium header mb-0">{{ community.metadata.title }} </h1>

<a class="remove-default-style" href="{{ community.links.self_html }}">
<h1 class="ui medium header mb-0">
{{ community.metadata.title }}
</h1>
</a>

{% if community.access.visibility == 'restricted' %}
<div class="rel-ml-1">
Expand Down Expand Up @@ -108,19 +115,17 @@ <h1 class="ui medium header mb-0">{{ community.metadata.title }} </h1>

<div
class="sixteen wide mobile sixteen wide tablet four wide computer right aligned middle aligned column">
{%- if not community_use_jinja_header %}
<a href="/uploads/new?community={{ community.slug }}"
class="ui positive button labeled icon rel-mt-1 theme-secondary">
<i class="upload icon" aria-hidden="true"></i>
{{ _("New upload") }}
</a>
{% endif %}
<a href="/uploads/new?community={{ community.slug }}"
class="ui positive button labeled icon rel-mt-1 theme-secondary">
<i class="upload icon" aria-hidden="true"></i>
{{ _("New upload") }}
</a>
<a href="{{'/support/'}}"
target="_blank"
class="ui positive item button labeled theme-primary icon rel-mt-1">
<i class="users icon" aria-hidden="true"></i>
{{ _("Join waiting list") }}
</a>
target="_blank"
class="ui positive item button labeled theme-primary icon rel-mt-1">
<i class="users icon" aria-hidden="true"></i>
{{ _("Join waiting list") }}
</a>
{% if permissions.can_moderate %}
<a
href="{{ url_for('administration.communities', q='slug:'+community.slug) }}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ <h1 class="ui text-muted small header">Builtin compliance with EU open science
<div class="ui rel-mt-2 rel-mb-4">
<div class="ui fluid container row rel-mb-2">
<a href="/uploads/new?community={{ community.slug }}"
target="_blank"
class="ui positive button labeled theme-secondary icon rel-mt-1">
<i class="upload icon" aria-hidden="true"></i>
{{ _("New upload") }}
Expand All @@ -52,26 +51,26 @@ <h1 class="ui text-muted small header">Builtin compliance with EU open science
{% if records %}
<div class="ui stackable theme-font grid container ">
<div class="column rel-mb-4">
<div class="row item">
<h1 class="ui large header">{{ title }}</h1>
</div>
<div class="ui divider"></div>
<div class="row item">
<h1 class="ui large header">{{ title }}</h1>
</div>
<div class="ui divider"></div>

<div class="ui fluid stackable three column grid">
{% for record in records %}
<ul class="ui column items m-0">
{{ record_item(record=record) }}
</ul>
{% endfor %}
</div>
<div class="ui fluid stackable three column grid">
{% for record in records %}
<ul class="ui column items m-0">
{{ record_item(record=record) }}
</ul>
{% endfor %}
</div>
</div>
</div>
{% endif %}

<div class="ui stackable theme-font grid container rel-mt-2">
<div class="column">
<div class="row item">
<h1 class="ui large header">{{ _('How it works?') }}</h1>
<h1 class="ui large header">{{ _('How it works') }}</h1>
</div>
<div class="ui divider"></div>
<div class="center aligned ui equal width stackable grid rel-mt-4 rel-mb-2">
Expand Down

0 comments on commit 01ea299

Please sign in to comment.