@@ -724,14 +724,44 @@ function configure_subsystem() {
724
724
deployments=
725
725
redirect_path=
726
726
727
- # We need it to be retrieved prior to iterate the web deployments, needed by CLI
728
- if [ -n " $token " ]; then
727
+ # We need it to be retrieved prior to iterate the web deployments, needed by CLI
728
+ if [ -n " $token " ]; then
729
+ # ## CIAM-690 -- Start of RH-SSO add-on:
730
+ # ## -----------------------------------
731
+ # ## Add support for RH-SSO 7.5
732
+
733
+ realm_signing_key_certificate=" xx"
734
+ # SSO Server 7.0
735
+ realm_certificate_url=" ${sso_service} /admin/realms/${SSO_REALM} "
736
+ response=$( ${CURL} -H " Accept: application/json" -H " Authorization: Bearer ${token} " " ${realm_certificate_url} " )
737
+ if ! grep -q ' "certificate":' <<< " ${response}" ; then
738
+ # SSO Server 7.1+
739
+ realm_certificate_url=" ${sso_service} /admin/realms/${SSO_REALM} /keys"
740
+ response=$( ${CURL} -H " Accept: application/json" -H " Authorization: Bearer ${token} " " ${realm_certificate_url} " )
741
+ if ! grep -q ' "certificate":' <<< " ${response}" ; then
742
+ echo " Failed to retrieve signing key PEM certificate of the ${SSO_REALM} "
743
+ exit 1
744
+ else
745
+ # SSO Server 7.1 up to 7.4
746
+ if ! grep -q ' "use":"SIG"' <<< " ${response}" ; then
747
+ realm_signing_key_certificate=$( grep -Po ' (?<="certificate":")[^"]*' <<< " ${response}" )
748
+ # SSO Server 7.5+
749
+ else
750
+ realm_signing_key_certificate=$( grep -Po ' (?<="certificate":")[^"]*(?=","use":"SIG")' <<< " ${response}" )
751
+ fi
752
+ fi
729
753
# SSO Server 7.0
730
- realm_certificate=$( $CURL -H " Accept: application/json" -H " Authorization: Bearer ${token} " ${sso_service} /admin/realms/${SSO_REALM} | grep -Po ' (?<="certificate":")[^"]*' )
731
- if [ -z " $realm_certificate " ]; then
732
- # SSO Server 7.1
733
- realm_certificate=$( $CURL -H " Accept: application/json" -H " Authorization: Bearer ${token} " ${sso_service} /admin/realms/${SSO_REALM} /keys | grep -Po ' (?<="certificate":")[^"]*' )
754
+ else
755
+ realm_signing_key_certificate=$( grep -Po ' (?<="certificate":")[^"]*' <<< " ${response}" )
756
+ fi
757
+
758
+ if [ " x${realm_signing_key_certificate} x" == " xx" ]; then
759
+ echo " Failed to retrieve signing key PEM certificate of the ${SSO_REALM} "
760
+ exit 1
734
761
fi
762
+
763
+ # ## CIAM-690 -- End of RH-SSO add-on
764
+ # ## --------------------------------
735
765
fi
736
766
737
767
for f in $files
@@ -822,7 +852,7 @@ function configure_subsystem() {
822
852
entity_id=${module_name}
823
853
fi
824
854
if [ $auth_method == ${SAML} ]; then
825
- if [ -n " $realm_certificate " ]; then
855
+ if [ -n " $realm_signing_key_certificate " ]; then
826
856
validate_signature=true
827
857
if [ -n " $SSO_SAML_VALIDATE_SIGNATURE " ]; then
828
858
validate_signature=" $SSO_SAML_VALIDATE_SIGNATURE "
@@ -839,9 +869,9 @@ function configure_subsystem() {
839
869
SingleLogoutService={validateRequestSignature=${validate_signature} ,validateResponseSignature=${validate_signature} ,signRequest=true,\
840
870
signResponse=true,requestBinding=POST,responseBinding=POST, postBindingUrl=${SSO_URL} /realms/${SSO_REALM} /protocol/saml,\
841
871
redirectBindingUrl=${SSO_URL} /realms/${SSO_REALM} /protocol/saml})"
842
- if [ -n " $realm_certificate " ]; then
872
+ if [ -n " $realm_signing_key_certificate " ]; then
843
873
cli=" $cli
844
- /subsystem=keycloak-saml/secure-deployment=${f} /SP=${entity_id} /IDP=idp/Key=Key:add(signing=true,CertificatePem=\" ${realm_certificate } \" )"
874
+ /subsystem=keycloak-saml/secure-deployment=${f} /SP=${entity_id} /IDP=idp/Key=Key:add(signing=true,CertificatePem=\" ${realm_signing_key_certificate } \" )"
845
875
fi
846
876
if [ -n " $SSO_SAML_KEYSTORE " ] && [ -n " $SSO_SAML_KEYSTORE_DIR " ]; then
847
877
cli=" $cli
@@ -929,8 +959,8 @@ function configure_subsystem() {
929
959
930
960
subsystem=$( echo " ${subsystem} " | sed " s|##KEYCLOAK_DEPLOYMENT_SUBSYSTEM##|${deployments} |" )
931
961
932
- if [ -n " $realm_certificate " ]; then
933
- keys=" <Keys><Key signing=\" true\" ><CertificatePem>${realm_certificate } </CertificatePem></Key></Keys>"
962
+ if [ -n " $realm_signing_key_certificate " ]; then
963
+ keys=" <Keys><Key signing=\" true\" ><CertificatePem>${realm_signing_key_certificate } </CertificatePem></Key></Keys>"
934
964
subsystem=$( echo " ${subsystem} " | sed " s|<!-- ##KEYCLOAK_REALM_CERTIFICATE## -->|${keys} |g" )
935
965
936
966
validate_signature=true
@@ -1132,4 +1162,4 @@ function query_routes_from_service() {
1132
1162
fi
1133
1163
fi
1134
1164
fi
1135
- }
1165
+ }
0 commit comments