Skip to content

Commit 31adca8

Browse files
committed
WIP: Add the dwh/grafana host name to keycloak redirect URIs
Without this, SSO login to grafana fails with this error, in keycloak.log: 2022-10-19 07:24:26,782Z WARN [org.keycloak.events] (default task-10) [] type=LOGIN_ERROR, realmId=256b7e9d-aff3-4a96-9979-85d2c07326bb, clientId=ovirt-engine-internal, userId=null, ipAddress=0:0:0:0:0:0:0:1, error=invalid_redirect_uri, redirect_uri=https://ost-separate-machine-basic-suite-master-dwh.lago.local/ovirt-engine-grafana/login/generic_oauth TODO: This should probably be done in dwh setup code or at least documented - it's not an issue specific to OST. Main obstacle, technically, is that we do not have the keycloak admin password, so ould have to ask the user, which is (at least) annoying. Change-Id: Icbdf559442da8f04c1669f574c0e401c0be4e25b Signed-off-by: Yedidyah Bar David <[email protected]>
1 parent 05d57f2 commit 31adca8

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

separate-machine-basic-suite-master/test-scenarios/test_001_initialize_engine_and_dwh.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,59 @@ def test_initialize_dwh(
6060
'--config-append=/root/dwh-answer-file '
6161
'--offline '
6262
)
63+
64+
65+
def test_add_dwh_to_keycloak_redirect_uris_for_grafana(
66+
ansible_engine,
67+
engine_fqdn,
68+
engine_password,
69+
dwh_fqdn,
70+
):
71+
def run_ansible_engine_kcadm(args):
72+
return ansible_engine.shell(
73+
'KC_OPTS=-Dcom.redhat.fips=false '
74+
'/usr/share/ovirt-engine-wildfly/bin/kcadm.sh '
75+
+ args
76+
)
77+
78+
# Set truststore, so that https works
79+
run_ansible_engine_kcadm(
80+
'config truststore '
81+
'--trustpass mypass /etc/pki/ovirt-engine/.truststore '
82+
)
83+
84+
# Login
85+
run_ansible_engine_kcadm(
86+
'config credentials '
87+
f'--server https://{engine_fqdn}/ovirt-engine-auth '
88+
'--realm master '
89+
'--user admin '
90+
f'--password {engine_password} '
91+
)
92+
93+
# Get the Id of the internal client. Various hard-coded strings here
94+
# must match relevant code/constants from ovirt-engine-keycloak.
95+
id_res = run_ansible_engine_kcadm(
96+
'get clients '
97+
'-r ovirt-internal '
98+
'-q clientId=ovirt-engine-internal '
99+
'--fields id '
100+
'--format csv'
101+
)
102+
id = id_res['stdout_lines'][0].strip('"')
103+
104+
# Get current URIs
105+
current_uris_res = run_ansible_engine_kcadm(
106+
f'get clients/{id} '
107+
'-r ovirt-internal '
108+
'--fields redirectUris '
109+
'--format csv'
110+
)
111+
current_uris = current_uris_res['stdout_lines'][0]
112+
113+
# Add dwh
114+
run_ansible_engine_kcadm(
115+
f'update clients/{id} '
116+
'-r ovirt-internal '
117+
f'-s redirectUris=\'[{current_uris}, "https://{dwh_fqdn}*"]\''
118+
)

0 commit comments

Comments
 (0)