Skip to content

Commit

Permalink
fix: jans-linux-setup set db component based on dn (#3290)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
devrimyatar committed Dec 13, 2022
1 parent 9e9a7bd commit 8d743f2
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 62 deletions.
24 changes: 0 additions & 24 deletions jans-linux-setup/jans_setup/schema/jans_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
18 changes: 11 additions & 7 deletions jans-linux-setup/jans_setup/setup_app/utils/db_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down

This file was deleted.

0 comments on commit 8d743f2

Please sign in to comment.