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
11 changes: 11 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,17 @@ jobs:
if: "${{ github.event.inputs.invenio-override-branch != '' && !startsWith( github.ref, 'refs/tags') }}"
run: sed -i 's/invenio-override", branch = "main"/invenio-override", branch = "${{ github.event.inputs.invenio-override-branch }}"/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"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
KEYCLOAK_NODE="cyverse"
KEYCLOAK_NODE="rdm"

else
KEYCLOAK_NODE="meduni"
fi
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
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
realm: CyVerse
realm: rdm

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)
29 changes: 6 additions & 23 deletions themes/MUG/invenio.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -392,12 +392,7 @@ 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
Expand All @@ -407,25 +402,13 @@ OAUTHCLIENT_KEYCLOAK_VERIFY_AUD = True # whether to verify the audience tag for
OAUTHCLIENT_KEYCLOAK_AUD = "inveniordm" # probably the same as the client ID
OAUTHCLIENT_KEYCLOAK_USER_INFO_FROM_ENDPOINT = True

# Cyverse SSO (commented out – uncomment to re-enable)
# _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,
"keycloak": _keycloak_helper.remote_app,
}

## SET THE CREDENTIALS via .env
Expand Down