Skip to content

Commit 8d743f2

Browse files
authored
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
1 parent 9e9a7bd commit 8d743f2

File tree

4 files changed

+12
-62
lines changed

4 files changed

+12
-62
lines changed

jans-linux-setup/jans_setup/schema/jans_schema.json

-24
Original file line numberDiff line numberDiff line change
@@ -4297,30 +4297,6 @@
42974297
],
42984298
"x_origin": "Jans created objectclass"
42994299
},
4300-
{
4301-
"kind": "STRUCTURAL",
4302-
"may": [
4303-
"c",
4304-
"ou",
4305-
"description",
4306-
"inum",
4307-
"displayName",
4308-
"jansConfDyn",
4309-
"o",
4310-
"jansRevision"
4311-
],
4312-
"must": [
4313-
"objectclass"
4314-
],
4315-
"names": [
4316-
"jansAdminConfDyn"
4317-
],
4318-
"oid": "jansObjClass",
4319-
"sup": [
4320-
"top"
4321-
],
4322-
"x_origin": "Jans created objectclass"
4323-
},
43244300
{
43254301
"kind": "STRUCTURAL",
43264302
"may": [

jans-linux-setup/jans_setup/setup_app/utils/db_utils.py

+11-7
Original file line numberDiff line numberDiff line change
@@ -285,29 +285,33 @@ def enable_service(self, service):
285285
n1ql = 'UPDATE `{}` USE KEYS "configuration" SET {}=true'.format(self.default_bucket, service)
286286
self.cbm.exec_query(n1ql)
287287

288-
def set_configuration(self, component, value):
288+
def set_configuration(self, component, value, dn='ou=configuration,o=jans'):
289289
if self.moddb == BackendTypes.LDAP:
290+
if value is None:
291+
value = []
290292
ldap_operation_result = self.ldap_conn.modify(
291-
'ou=configuration,o=jans',
293+
dn,
292294
{component: [ldap3.MODIFY_REPLACE, value]}
293295
)
294296
self.log_ldap_result(ldap_operation_result)
295297

296298
elif self.moddb in (BackendTypes.MYSQL, BackendTypes.PGSQL):
297-
result = self.get_sqlalchObj_for_dn('ou=configuration,o=jans')
299+
result = self.get_sqlalchObj_for_dn(dn)
298300
table_name = result.objectClass
299301
sqlalchemy_table = self.Base.classes[table_name]
300-
sqlalchemyObj = self.session.query(sqlalchemy_table).filter(sqlalchemy_table.dn =='ou=configuration,o=jans').first()
302+
sqlalchemyObj = self.session.query(sqlalchemy_table).filter(sqlalchemy_table.dn ==dn).first()
301303
cur_val = getattr(sqlalchemyObj, component)
302304
setattr(sqlalchemyObj, component, value)
303305
self.session.commit()
304306

305307
elif self.moddb == BackendTypes.SPANNER:
306-
self.spanner.update_data(table='jansAppConf', columns=["doc_id", component], values=[["configuration", value]])
307-
308+
table = self.get_spanner_table_for_dn(dn)
309+
doc_id = self.get_doc_id_from_dn(dn)
310+
self.spanner.update_data(table=table, columns=["doc_id", component], values=[[doc_id, value]])
308311

309312
elif self.moddb == BackendTypes.COUCHBASE:
310-
n1ql = 'UPDATE `{}` USE KEYS "configuration" SET {}={}'.format(self.default_bucket, component, value)
313+
key = ldif_utils.get_key_from(dn)
314+
n1ql = 'UPDATE `{}` USE KEYS "{}" SET {}={}'.format(self.default_bucket, key, component, value)
311315
self.cbm.exec_query(n1ql)
312316

313317

jans-linux-setup/jans_setup/templates/jans-auth/role-scope-mappings.ldif

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
version: 1
22
dn: ou=admin-ui,ou=configuration,o=jans
3-
objectClass: jansAdminConfDyn
3+
objectClass: jansAppConf
44
objectClass: top
55
jansConfDyn: %(role_scope_mappings)s
66
jansRevision: 1

jans-linux-setup/jans_setup/templates/jans-config-api/auiConfiguration.properties

-30
This file was deleted.

0 commit comments

Comments
 (0)