Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,16 @@ jobs:
- name: Change pyproject.toml override MUG
run: sed -i 's/-override ~/-override[marc21] ~/g' pyproject.toml

- name: Set keycloak in invenio.cfg via script
run: |
source .venv/bin/activate
if [[ ${{ !startsWith( github.ref, 'refs/tags') }}]]; then
KEYCLOAK_NODE="cyverse"
else
KEYCLOAK_NODE="meduni"
python auth/yaml2py.py --source-filename auth/kc-settings-pool.yaml --dest-filename themes/MUG/invenio.cfg --node $KEYCLOAK_NODE --placeholder "<insert_keycloak_config_via_ci>"
deactivate

- name: Relock uv
run: |
source .venv/bin/activate
Expand Down
15 changes: 15 additions & 0 deletions auth/kc-settings-pool.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
cyverse:
title: "Cyverse SSO"
description: Cyverse SSO
base_url: https://keycloak.cyverse.at
realm: CyVerse
app_key: CYVERSE_KEYCLOAK_APP_CREDENTIALS
legacy_url_path: False

meduni:
title: Meduni SSO
description: Meduni SSO
base_url: https://openid.medunigraz.at/
realm: invenioRDM
app_key: KEYCLOAK_APP_CREDENTIALS
legacy_url_path: False
34 changes: 34 additions & 0 deletions auth/yaml2py.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
"""
Script that injects a given yaml config into arguments of an invenio.cfg class.
"""

import yaml
import sys
import argparse

parser = argparse.ArgumentParser()

parser.add_argument('--source-filename', type=str, required=True)
parser.add_argument('--dest-filename', type=str, required=True)
parser.add_argument('--node', type=str, required=True)
parser.add_argument('--placeholder', type=str, required=True)

args = parser.parse_args()

auth_config = ""
with open(args.source_filename) as f:
data = yaml.safe_load(f)
for key, _ in data.items():
if key == args.node:
for node_key, val in data[key].items():
if isinstance(val, str):
auth_config += f'{node_key}="{val}",\n'
else:
auth_config += f'{node_key}={val},\n'

with open(args.dest_filename, "r") as f:
config = f.read()
config = config.replace(args.placeholder, auth_config)

with open(args.dest_filename, "w") as f:
f.write(config)
34 changes: 5 additions & 29 deletions themes/MUG/invenio.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -392,39 +392,15 @@ GLOBAL_SEARCH_SCHEMAS = {
# Keycloak configurations
# ============================================================================
_keycloak_helper = KeycloakSettingsHelper(
title="Meduni SSO",
description="Meduni SSO",
base_url="https://openid.medunigraz.at/",
realm="invenioRDM",
app_key="KEYCLOAK_APP_CREDENTIALS",
legacy_url_path=False
<insert_keycloak_config_via_ci>
)

OAUTHCLIENT_KEYCLOAK_REALM_URL = _keycloak_helper.realm_url
OAUTHCLIENT_KEYCLOAK_USER_INFO_URL = _keycloak_helper.user_info_url
OAUTHCLIENT_KEYCLOAK_VERIFY_EXP = True # whether to verify the expiration date of tokens
OAUTHCLIENT_KEYCLOAK_VERIFY_AUD = True # whether to verify the audience tag for tokens
OAUTHCLIENT_KEYCLOAK_AUD = "inveniordm" # probably the same as the client ID
OAUTHCLIENT_KEYCLOAK_USER_INFO_FROM_ENDPOINT = True

_cyverse_keycloak_helper = KeycloakSettingsHelper(
title="Cyverse SSO",
description="Cyverse SSO",
base_url="https://keycloak.cyverse.at",
realm="CyVerse",
app_key="CYVERSE_KEYCLOAK_APP_CREDENTIALS",
)
OAUTHCLIENT_CYVERSE_REALM_URL = _cyverse_keycloak_helper.realm_url
OAUTHCLIENT_CYVERSE_USER_INFO_URL = _cyverse_keycloak_helper.user_info_url
OAUTHCLIENT_CYVERSE_VERIFY_EXP = True
OAUTHCLIENT_CYVERSE_VERIFY_AUD = True
OAUTHCLIENT_CYVERSE_AUD = "inveniordm"
OAUTHCLIENT_CYVERSE_USER_INFO_FROM_ENDPOINT = True

"""
Keycloak settings like base_url and realm should be set by CI by replacing for
the placeholder this instance.
"""

OAUTHCLIENT_REMOTE_APPS = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about this?

Copy link
Contributor Author

@edivalentinitu edivalentinitu Jan 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we will have only one app which will have the configuration injected at CI runtime. maybe as a future task we could extend the template to add multiple configs/apps.

"keycloak": _keycloak_helper.remote_app,
"cyverse": _cyverse_keycloak_helper.remote_app,
}

## SET THE CREDENTIALS via .env
Expand Down