Skip to content

Commit 027944b

Browse files
jageeevallesp
authored andcommitted
Add support for multiple IdP providers in Federation
This patch will setup two realms in keycloak. Keystone will be configured to work with these two realms as different IdPs. Each realm will get its own mapping in openstack. It will also enable these two IdP choices to the horizon UI. Jira: https://issues.redhat.com/browse/OSPRH-14033
1 parent a7af7d8 commit 027944b

21 files changed

+834
-257
lines changed

docs/dictionary/en-custom.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,7 @@ nwy
389389
nzgdh
390390
oauth
391391
observability
392+
oidc
392393
oc
393394
ocp
394395
ocpbm
@@ -399,6 +400,7 @@ ol
399400
olm
400401
oob
401402
opendev
403+
openid
402404
openrc
403405
openscap
404406
openshift
@@ -617,6 +619,7 @@ vvvv
617619
vxlan
618620
vynxgdagahaac
619621
vzcg
622+
websso
620623
wget
621624
whitebox
622625
wljewmdozmzawlzasdje

hooks/playbooks/federation-controlplane-config.yml

Lines changed: 8 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -2,117 +2,17 @@
22
- name: Create kustomization to update Keystone to use Federation
33
hosts: "{{ cifmw_target_hook_host | default('localhost') }}"
44
tasks:
5-
- name: Set urls for install type uni
5+
- name: Set uni domain name var from federation role
66
ansible.builtin.set_fact:
7-
cifmw_federation_keycloak_url: 'https://keycloak-openstack.apps.ocp.openstack.lab'
8-
cifmw_federation_keystone_url: 'https://keystone-public-openstack.apps.ocp.openstack.lab'
9-
cifmw_federation_horizon_url: 'https://horizon-openstack.apps.ocp.openstack.lab'
7+
cifmw_federation_domain: "apps.ocp.openstack.lab"
108
when: cifmw_federation_deploy_type == "uni"
119

12-
- name: Set urls for install type crc
10+
- name: Set crc domain name var from federation role
1311
ansible.builtin.set_fact:
14-
cifmw_federation_keycloak_url: 'https://keycloak-openstack.apps-crc.testing'
15-
cifmw_federation_keystone_url: 'https://keystone-public-openstack.apps-crc.testing'
16-
cifmw_federation_horizon_url: 'https://horizon-openstack.apps-crc.testing'
12+
cifmw_federation_domain: "apps-crc.testing"
1713
when: cifmw_federation_deploy_type == "crc"
1814

19-
- name: Create file to customize keystone for Federation resources deployed in the control plane
20-
ansible.builtin.copy:
21-
dest: "{{ cifmw_basedir }}/artifacts/manifests/kustomizations/controlplane/keystone_federation.yaml"
22-
content: |-
23-
apiVersion: kustomize.config.k8s.io/v1beta1
24-
kind: Kustomization
25-
resources:
26-
- namespace: {{ namespace }}
27-
patches:
28-
- target:
29-
kind: OpenStackControlPlane
30-
name: .*
31-
patch: |-
32-
- op: add
33-
path: /spec/tls
34-
value: {}
35-
- op: add
36-
path: /spec/tls/caBundleSecretName
37-
value: keycloakca
38-
- op: add
39-
path: /spec/keystone/template/httpdCustomization
40-
value:
41-
customConfigSecret: keystone-httpd-override
42-
- op: add
43-
path: /spec/keystone/template/customServiceConfig
44-
value: |
45-
[DEFAULT]
46-
insecure_debug=true
47-
debug=true
48-
[federation]
49-
trusted_dashboard={{ cifmw_federation_horizon_url }}/dashboard/auth/websso/
50-
sso_callback_template=/etc/keystone/sso_callback_template.html
51-
[openid]
52-
remote_id_attribute=HTTP_OIDC_ISS
53-
[auth]
54-
methods = password,token,oauth1,mapped,application_credential,openid
55-
mode: "0644"
56-
57-
- name: Get ingress operator CA cert
58-
ansible.builtin.slurp:
59-
src: "{{ [ ansible_user_dir, 'ci-framework-data', 'tmp', 'ingress-operator-ca.crt'] | path_join }}"
60-
register: federation_sso_ca
61-
62-
- name: Add Keycloak CA secret
63-
kubernetes.core.k8s:
64-
kubeconfig: "{{ cifmw_openshift_kubeconfig }}"
65-
state: present
66-
definition:
67-
apiVersion: v1
68-
kind: Secret
69-
type: Opaque
70-
metadata:
71-
name: keycloakca
72-
namespace: "openstack"
73-
data:
74-
KeyCloakCA: "{{ federation_sso_ca.content }}"
75-
76-
- name: Create Keystone httpd override secret for Federation
77-
kubernetes.core.k8s:
78-
kubeconfig: "{{ cifmw_openshift_kubeconfig }}"
79-
state: present
80-
definition:
81-
apiVersion: v1
82-
kind: Secret
83-
metadata:
84-
name: keystone-httpd-override
85-
namespace: openstack
86-
type: Opaque
87-
stringData:
88-
federation.conf: |
89-
OIDCClaimPrefix "{{ cifmw_keystone_OIDC_ClaimPrefix }}"
90-
OIDCResponseType "{{ cifmw_keystone_OIDC_ResponseType }}"
91-
OIDCScope "{{ cifmw_keystone_OIDC_Scope }}"
92-
OIDCClaimDelimiter "{{ cifmw_keystone_OIDC_ClaimDelimiter }}"
93-
OIDCPassUserInfoAs "{{ cifmw_keystone_OIDC_PassUserInfoAs }}"
94-
OIDCPassClaimsAs "{{ cifmw_keystone_OIDC_PassClaimsAs }}"
95-
OIDCProviderMetadataURL "{{ cifmw_keystone_OIDC_ProviderMetadataURL }}"
96-
OIDCClientID "{{ cifmw_keystone_OIDC_ClientID }}"
97-
OIDCClientSecret "{{ cifmw_keystone_OIDC_ClientSecret }}"
98-
OIDCCryptoPassphrase "{{ cifmw_keystone_OIDC_CryptoPassphrase }}"
99-
OIDCOAuthClientID "{{ cifmw_keystone_OIDC_OAuthClientID }}"
100-
OIDCOAuthClientSecret "{{ cifmw_keystone_OIDC_OAuthClientSecret }}"
101-
OIDCOAuthIntrospectionEndpoint "{{ cifmw_keystone_OIDC_OAuthIntrospectionEndpoint }}"
102-
OIDCRedirectURI "{{ cifmw_federation_keystone_url }}/v3/auth/OS-FEDERATION/identity_providers/{{ cifmw_keystone_OIDC_provider_name }}/protocols/openid/websso/"
103-
LogLevel debug
104-
105-
<LocationMatch "/v3/auth/OS-FEDERATION/identity_providers/{{ cifmw_keystone_OIDC_provider_name }}/protocols/openid/websso">
106-
AuthType "openid-connect"
107-
Require valid-user
108-
</LocationMatch>
109-
110-
<Location ~ "/v3/OS-FEDERATION/identity_providers/{{ cifmw_keystone_OIDC_provider_name }}/protocols/openid/auth">
111-
AuthType oauth20
112-
Require valid-user
113-
</Location>
114-
115-
<LocationMatch "/v3/auth/OS-FEDERATION/websso/openid">
116-
AuthType "openid-connect"
117-
Require valid-user
118-
</LocationMatch>
15+
- name: Run SSO controlplane setup
16+
ansible.builtin.import_role:
17+
name: federation
18+
tasks_from: hook_controlplane_config.yml

hooks/playbooks/federation-horizon-controlplane-config.yml

Lines changed: 8 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2,49 +2,17 @@
22
- name: Create kustomization to update Horizon to use Federation
33
hosts: "{{ cifmw_target_hook_host | default('localhost') }}"
44
tasks:
5-
- name: Set urls for install type uni
5+
- name: Read uni vars from federation role
66
ansible.builtin.set_fact:
7-
cifmw_federation_keycloak_url: 'https://keycloak-openstack.apps.ocp.openstack.lab'
8-
cifmw_federation_keystone_url: 'https://keystone-public-openstack.apps.ocp.openstack.lab'
9-
cifmw_federation_horizon_url: 'https://horizon-openstack.apps.ocp.openstack.lab'
7+
cifmw_federation_domain: "apps.ocp.openstack.lab"
108
when: cifmw_federation_deploy_type == "uni"
119

12-
- name: Set urls for install type crc
10+
- name: Read crc vars from federation role
1311
ansible.builtin.set_fact:
14-
cifmw_federation_keycloak_url: 'https://keycloak-openstack.apps-crc.testing'
15-
cifmw_federation_keystone_url: 'https://keystone-public-openstack.apps-crc.testing'
16-
cifmw_federation_horizon_url: 'https://horizon-openstack.apps-crc.testing'
12+
cifmw_federation_domain: "apps-crc.testing"
1713
when: cifmw_federation_deploy_type == "crc"
1814

19-
- name: Create file to customize horizon for Federation resources deployed in the control plane
20-
ansible.builtin.copy:
21-
dest: "{{ cifmw_basedir }}/artifacts/manifests/kustomizations/controlplane/horizon_federation.yaml"
22-
mode: preserve
23-
content: |-
24-
apiVersion: kustomize.config.k8s.io/v1beta1
25-
kind: Kustomization
26-
resources:
27-
- namespace: {{ namespace }}
28-
patches:
29-
- target:
30-
kind: OpenStackControlPlane
31-
name: .*
32-
patch: |-
33-
- op: add
34-
path: /spec/horizon/enabled
35-
value: true
36-
- op: add
37-
path: /spec/horizon/template/memcachedInstance
38-
value: memcached
39-
- op: add
40-
path: /spec/horizon/template/customServiceConfig
41-
value: |
42-
OPENSTACK_KEYSTONE_URL = "{{ cifmw_federation_keystone_url }}/v3"
43-
WEBSSO_ENABLED = True
44-
WEBSSO_CHOICES = (
45-
("credentials", _("Keystone Credentials")),
46-
("OIDC", _("OpenID Connect")),
47-
)
48-
WEBSSO_IDP_MAPPING = {
49-
"OIDC": ("{{ cifmw_keystone_OIDC_provider_name }}", "openid"),
50-
}
15+
- name: Run SSO MultiRealm controlplane setup
16+
ansible.builtin.import_role:
17+
name: federation
18+
tasks_from: hook_horizon_controlplane_config.yml
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
- name: Create kustomization to update Keystone to use MultiRealm Federation
3+
hosts: "{{ cifmw_target_hook_host | default('localhost') }}"
4+
tasks:
5+
- name: Set uni domain name var from federation role
6+
ansible.builtin.set_fact:
7+
cifmw_federation_domain: "apps.ocp.openstack.lab"
8+
when: cifmw_federation_deploy_type == "uni"
9+
10+
- name: Set crc domain name var from federation role
11+
ansible.builtin.set_fact:
12+
cifmw_federation_domain: "apps-crc.testing"
13+
when: cifmw_federation_deploy_type == "crc"
14+
15+
- name: Run SSO MultiRealm controlplane setup
16+
ansible.builtin.import_role:
17+
name: federation
18+
tasks_from: hook_multirealm_controlplane_config.yml

hooks/playbooks/federation-post-deploy.yml

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,26 +18,17 @@
1818
hosts: "{{ cifmw_target_host | default('localhost') }}"
1919
gather_facts: true
2020
tasks:
21-
- name: Set urls for install type uni
21+
- name: Set uni domain name var from federation role
2222
ansible.builtin.set_fact:
23-
cifmw_federation_keycloak_url: 'https://keycloak-openstack.apps.ocp.openstack.lab'
24-
cifmw_federation_keystone_url: 'https://keystone-public-openstack.apps.ocp.openstack.lab'
25-
cifmw_federation_horizon_url: 'https://horizon-openstack.apps.ocp.openstack.lab'
23+
cifmw_federation_domain: "apps.ocp.openstack.lab"
2624
when: cifmw_federation_deploy_type == "uni"
2725

28-
- name: Set urls for install type crc
26+
- name: Set crc domain name var from federation role
2927
ansible.builtin.set_fact:
30-
cifmw_federation_keycloak_url: 'https://keycloak-openstack.apps-crc.testing'
31-
cifmw_federation_keystone_url: 'https://keystone-public-openstack.apps-crc.testing'
32-
cifmw_federation_horizon_url: 'https://horizon-openstack.apps-crc.testing'
28+
cifmw_federation_domain: "apps-crc.testing"
3329
when: cifmw_federation_deploy_type == "crc"
3430

35-
- name: Run federation setup on OSP
31+
- name: Run federation post hook setup on OSP
3632
ansible.builtin.import_role:
3733
name: federation
38-
tasks_from: run_openstack_setup.yml
39-
40-
- name: Run federation OSP User Auth test
41-
ansible.builtin.import_role:
42-
name: federation
43-
tasks_from: run_openstack_auth_test.yml
34+
tasks_from: hook_post_deploy.yml

hooks/playbooks/federation-pre-deploy.yml

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,26 +18,17 @@
1818
hosts: "{{ cifmw_target_host | default('localhost') }}"
1919
gather_facts: true
2020
tasks:
21-
- name: Set urls for install type uni
21+
- name: Set uni domain name var from federation role
2222
ansible.builtin.set_fact:
23-
cifmw_federation_keycloak_url: 'https://keycloak-openstack.apps.ocp.openstack.lab'
24-
cifmw_federation_keystone_url: 'https://keystone-public-openstack.apps.ocp.openstack.lab'
25-
cifmw_federation_horizon_url: 'https://horizon-openstack.apps.ocp.openstack.lab'
23+
cifmw_federation_domain: "apps.ocp.openstack.lab"
2624
when: cifmw_federation_deploy_type == "uni"
2725

28-
- name: Set urls for install type crc
26+
- name: Set crc domain name var from federation role
2927
ansible.builtin.set_fact:
30-
cifmw_federation_keycloak_url: 'https://keycloak-openstack.apps-crc.testing'
31-
cifmw_federation_keystone_url: 'https://keystone-public-openstack.apps-crc.testing'
32-
cifmw_federation_horizon_url: 'https://horizon-openstack.apps-crc.testing'
28+
cifmw_federation_domain: "apps-crc.testing"
3329
when: cifmw_federation_deploy_type == "crc"
3430

35-
- name: Run SSO pod setup on Openshift
31+
- name: Run SSO pre deploy setup
3632
ansible.builtin.import_role:
3733
name: federation
38-
tasks_from: run_keycloak_setup.yml
39-
40-
- name: Run SSO realm setup for OSP
41-
ansible.builtin.import_role:
42-
name: federation
43-
tasks_from: run_keycloak_realm_setup.yml
34+
tasks_from: hook_pre_deploy.yml

0 commit comments

Comments
 (0)