From 8d743f21c0f723c2891155711a13ec8f5300b08a Mon Sep 17 00:00:00 2001 From: Devrim Date: Tue, 13 Dec 2022 13:56:09 +0300 Subject: [PATCH] fix: jans-linux-setup set db component based on dn (#3290) * fix: jans-linux-setup set db component based on dn * fix: jans-linux-setup remove auiConfiguration.properties * fix: jans-linux-setup set_configuration() for CB * fix: jans-linux-setup admin-ui schema --- .../jans_setup/schema/jans_schema.json | 24 --------------- .../jans_setup/setup_app/utils/db_utils.py | 18 ++++++----- .../jans-auth/role-scope-mappings.ldif | 2 +- .../auiConfiguration.properties | 30 ------------------- 4 files changed, 12 insertions(+), 62 deletions(-) delete mode 100644 jans-linux-setup/jans_setup/templates/jans-config-api/auiConfiguration.properties diff --git a/jans-linux-setup/jans_setup/schema/jans_schema.json b/jans-linux-setup/jans_setup/schema/jans_schema.json index 1a36820e934..3658ccb0a35 100644 --- a/jans-linux-setup/jans_setup/schema/jans_schema.json +++ b/jans-linux-setup/jans_setup/schema/jans_schema.json @@ -4297,30 +4297,6 @@ ], "x_origin": "Jans created objectclass" }, - { - "kind": "STRUCTURAL", - "may": [ - "c", - "ou", - "description", - "inum", - "displayName", - "jansConfDyn", - "o", - "jansRevision" - ], - "must": [ - "objectclass" - ], - "names": [ - "jansAdminConfDyn" - ], - "oid": "jansObjClass", - "sup": [ - "top" - ], - "x_origin": "Jans created objectclass" - }, { "kind": "STRUCTURAL", "may": [ diff --git a/jans-linux-setup/jans_setup/setup_app/utils/db_utils.py b/jans-linux-setup/jans_setup/setup_app/utils/db_utils.py index a6d8fd97d64..e95559bd9b5 100644 --- a/jans-linux-setup/jans_setup/setup_app/utils/db_utils.py +++ b/jans-linux-setup/jans_setup/setup_app/utils/db_utils.py @@ -285,29 +285,33 @@ def enable_service(self, service): n1ql = 'UPDATE `{}` USE KEYS "configuration" SET {}=true'.format(self.default_bucket, service) self.cbm.exec_query(n1ql) - def set_configuration(self, component, value): + def set_configuration(self, component, value, dn='ou=configuration,o=jans'): if self.moddb == BackendTypes.LDAP: + if value is None: + value = [] ldap_operation_result = self.ldap_conn.modify( - 'ou=configuration,o=jans', + dn, {component: [ldap3.MODIFY_REPLACE, value]} ) self.log_ldap_result(ldap_operation_result) elif self.moddb in (BackendTypes.MYSQL, BackendTypes.PGSQL): - result = self.get_sqlalchObj_for_dn('ou=configuration,o=jans') + result = self.get_sqlalchObj_for_dn(dn) table_name = result.objectClass sqlalchemy_table = self.Base.classes[table_name] - sqlalchemyObj = self.session.query(sqlalchemy_table).filter(sqlalchemy_table.dn =='ou=configuration,o=jans').first() + sqlalchemyObj = self.session.query(sqlalchemy_table).filter(sqlalchemy_table.dn ==dn).first() cur_val = getattr(sqlalchemyObj, component) setattr(sqlalchemyObj, component, value) self.session.commit() elif self.moddb == BackendTypes.SPANNER: - self.spanner.update_data(table='jansAppConf', columns=["doc_id", component], values=[["configuration", value]]) - + table = self.get_spanner_table_for_dn(dn) + doc_id = self.get_doc_id_from_dn(dn) + self.spanner.update_data(table=table, columns=["doc_id", component], values=[[doc_id, value]]) elif self.moddb == BackendTypes.COUCHBASE: - n1ql = 'UPDATE `{}` USE KEYS "configuration" SET {}={}'.format(self.default_bucket, component, value) + key = ldif_utils.get_key_from(dn) + n1ql = 'UPDATE `{}` USE KEYS "{}" SET {}={}'.format(self.default_bucket, key, component, value) self.cbm.exec_query(n1ql) diff --git a/jans-linux-setup/jans_setup/templates/jans-auth/role-scope-mappings.ldif b/jans-linux-setup/jans_setup/templates/jans-auth/role-scope-mappings.ldif index ccf430d02d1..007edcdaf24 100644 --- a/jans-linux-setup/jans_setup/templates/jans-auth/role-scope-mappings.ldif +++ b/jans-linux-setup/jans_setup/templates/jans-auth/role-scope-mappings.ldif @@ -1,6 +1,6 @@ version: 1 dn: ou=admin-ui,ou=configuration,o=jans -objectClass: jansAdminConfDyn +objectClass: jansAppConf objectClass: top jansConfDyn: %(role_scope_mappings)s jansRevision: 1 diff --git a/jans-linux-setup/jans_setup/templates/jans-config-api/auiConfiguration.properties b/jans-linux-setup/jans_setup/templates/jans-config-api/auiConfiguration.properties deleted file mode 100644 index f7ff352612d..00000000000 --- a/jans-linux-setup/jans_setup/templates/jans-config-api/auiConfiguration.properties +++ /dev/null @@ -1,30 +0,0 @@ -authserver.clientId=%(role_based_client_id)s -authserver.clientSecret=%(role_based_client_pw)s -authserver.authzBaseUrl=https://%(hostname)s/jans-auth/authorize.htm -authserver.scope=openid+profile+email+user_name -authserver.redirectUrl=https://%(hostname)s/admin -authserver.frontChannelLogoutUrl=https://%(hostname)s/admin/logout -authserver.postLogoutRedirectUri=https://%(hostname)s/admin -authserver.tokenEndpoint=https://%(hostname)s/jans-auth/restv1/token -authserver.introspectionEndpoint=https://%(hostname)s/jans-auth/restv1/introspection -authserver.userInfoEndpoint=https://%(hostname)s/jans-auth/restv1/userinfo -authserver.endSessionEndpoint=https://%(hostname)s/jans-auth/restv1/end_session - -tokenServer.clientId=%(role_based_client_id)s -tokenServer.clientSecret=%(role_based_client_pw)s -tokenServer.authzBaseUrl=https://%(hostname)s/jans-auth/authorize.htm -tokenServer.scope=openid+profile+email+user_name -tokenServer.redirectUrl=https://%(hostname)s/admin -tokenServer.logoutUrl=https://%(hostname)s/admin -tokenServer.tokenEndpoint=https://%(hostname)s/jans-auth/restv1/token -tokenServer.introspectionEndpoint=https://%(hostname)s/jans-auth/restv1/introspection -tokenServer.userInfoEndpoint=https://%(hostname)s/jans-auth/restv1/userinfo - - -## licenseSpring details - -licenseSpring.apiKey=9816ef29-a5fa-4df7-bba7-b7ae83711d28 -licenseSpring.productCode=adminui001 -licenseSpring.sharedKey=FW4xYR1nFnY6ISWulhMOYSBqx1Li_10D74RznCZxVtQ -licenseSpring.managementKey=raGfAOAy.y9oyJYZaBb8rlM4yfTbNUB7l8InWdE2l -licenseSpring.enabled=false