From ef8c330cd984684c91a569aebfdc4c8bc192d826 Mon Sep 17 00:00:00 2001 From: asteroide Date: Mon, 27 Jul 2015 17:42:05 +0200 Subject: Add, del, set subjects in both IntraAuthzExtension, IntraAdminExtension. (untested) Change-Id: Ifca8f915fd50e3557478d9e3dcc1cd96dc22e277 --- keystone-moon/keystone/contrib/moon/core.py | 70 ++++++++++++++++++++++++----- 1 file changed, 58 insertions(+), 12 deletions(-) (limited to 'keystone-moon/keystone/contrib') diff --git a/keystone-moon/keystone/contrib/moon/core.py b/keystone-moon/keystone/contrib/moon/core.py index e7d606c6..5685a538 100644 --- a/keystone-moon/keystone/contrib/moon/core.py +++ b/keystone-moon/keystone/contrib/moon/core.py @@ -1538,16 +1538,39 @@ class IntraExtensionAuthzManager(IntraExtensionManager): return super(IntraExtensionAuthzManager, self).authz(intra_extension_id, subject_id, object_id, action_id) def add_subject_dict(self, user_id, intra_extension_id, subject_dict): - # TODO: sync with intra_admin_extension subjects table, need double check in both authz and admin - return + subject = super(IntraExtensionAuthzManager, self).set_subject_dict(user_id, intra_extension_id, subject_dict) + tenants_dict = self.tenant_api.get_tenants_dict(ADMIN_ID) + for tenant_id in tenants_dict: + if tenants_dict[tenant_id]["intra_authz_extension_id"] == intra_extension_id: + self.driver.set_subject_dict(tenants_dict[tenant_id]["intra_admin_extension_id"], subject['id'], subject_dict) + break + if tenants_dict[tenant_id]["intra_admin_extension_id"] == intra_extension_id: + self.driver.set_subject_dict(tenants_dict[tenant_id]["intra_authz_extension_id"], subject['id'], subject_dict) + break + return subject def del_subject(self, user_id, intra_extension_id, subject_id): - # TODO: sync with intra_admin_extension subjects table, need double check in both authz and admin - pass + super(IntraExtensionAuthzManager, self).del_subject(user_id, intra_extension_id, subject_id) + tenants_dict = self.tenant_api.get_tenants_dict(ADMIN_ID) + for tenant_id in tenants_dict: + if tenants_dict[tenant_id]["intra_authz_extension_id"] == intra_extension_id: + self.driver.del_subject(tenants_dict[tenant_id]["intra_admin_extension_id"], subject_id) + break + if tenants_dict[tenant_id]["intra_admin_extension_id"] == intra_extension_id: + self.driver.del_subject(tenants_dict[tenant_id]["intra_authz_extension_id"], subject_id) + break def set_subject_dict(self, user_id, intra_extension_id, subject_id, subject_dict): - # TODO: sync with intra_admin_extension subjects table, need double check in both authz and admin - return + subject = super(IntraExtensionAuthzManager, self).set_subject_dict(user_id, intra_extension_id, subject_dict) + tenants_dict = self.tenant_api.get_tenants_dict(ADMIN_ID) + for tenant_id in tenants_dict: + if tenants_dict[tenant_id]["intra_authz_extension_id"] == intra_extension_id: + self.driver.set_subject_dict(tenants_dict[tenant_id]["intra_admin_extension_id"], subject['id'], subject_dict) + break + if tenants_dict[tenant_id]["intra_admin_extension_id"] == intra_extension_id: + self.driver.set_subject_dict(tenants_dict[tenant_id]["intra_authz_extension_id"], subject['id'], subject_dict) + break + return subject # TODO: for other no heritaged functions, add raise AuthzException() @@ -1559,16 +1582,39 @@ class IntraExtensionAdminManager(IntraExtensionManager): super(IntraExtensionAdminManager, self).__init__() def add_subject_dict(self, user_id, intra_extension_id, subject_dict): - # TODO: sync with intra_authz_extension subjects table, need double check in both authz and admin - return + subject = super(IntraExtensionAdminManager, self).set_subject_dict(user_id, intra_extension_id, subject_dict) + tenants_dict = self.tenant_api.get_tenants_dict(ADMIN_ID) + for tenant_id in tenants_dict: + if tenants_dict[tenant_id]["intra_authz_extension_id"] == intra_extension_id: + self.driver.set_subject_dict(tenants_dict[tenant_id]["intra_admin_extension_id"], subject['id'], subject_dict) + break + if tenants_dict[tenant_id]["intra_admin_extension_id"] == intra_extension_id: + self.driver.set_subject_dict(tenants_dict[tenant_id]["intra_authz_extension_id"], subject['id'], subject_dict) + break + return subject def del_subject(self, user_id, intra_extension_id, subject_id): - # TODO: sync with intra_authz_extension subjects table, need double check in both authz and admin - pass + super(IntraExtensionAdminManager, self).del_subject(user_id, intra_extension_id, subject_id) + tenants_dict = self.tenant_api.get_tenants_dict(ADMIN_ID) + for tenant_id in tenants_dict: + if tenants_dict[tenant_id]["intra_authz_extension_id"] == intra_extension_id: + self.driver.del_subject(tenants_dict[tenant_id]["intra_admin_extension_id"], subject_id) + break + if tenants_dict[tenant_id]["intra_admin_extension_id"] == intra_extension_id: + self.driver.del_subject(tenants_dict[tenant_id]["intra_authz_extension_id"], subject_id) + break def set_subject_dict(self, user_id, intra_extension_id, subject_id, subject_dict): - # TODO: sync with intra_authz_extension subjects table, need double check in both authz and admin - return + subject = super(IntraExtensionAdminManager, self).set_subject_dict(user_id, intra_extension_id, subject_dict) + tenants_dict = self.tenant_api.get_tenants_dict(ADMIN_ID) + for tenant_id in tenants_dict: + if tenants_dict[tenant_id]["intra_authz_extension_id"] == intra_extension_id: + self.driver.set_subject_dict(tenants_dict[tenant_id]["intra_admin_extension_id"], subject['id'], subject_dict) + break + if tenants_dict[tenant_id]["intra_admin_extension_id"] == intra_extension_id: + self.driver.set_subject_dict(tenants_dict[tenant_id]["intra_authz_extension_id"], subject['id'], subject_dict) + break + return subject def add_object_dict(self, user_id, intra_extension_id, object_name): raise ObjectsWriteNoAuthorized() -- cgit 1.2.3-korg