From abcc2cbec338d22d86bd64f1af89e780cdad5a9f Mon Sep 17 00:00:00 2001
From: Jan Cholasta <jcholast@redhat.com>
Date: Thu, 3 Sep 2015 09:32:11 +0200
Subject: [PATCH] vault: add permissions and administrator privilege
https://fedorahosted.org/freeipa/ticket/5250
Reviewed-By: Petr Vobornik <pvoborni@redhat.com>
---
ACI.txt | 22 ++++++++
install/updates/40-delegation.update | 8 +++
ipalib/plugins/vault.py | 98 ++++++++++++++++++++++++++++++++++++
3 files changed, 128 insertions(+)
diff --git a/ACI.txt b/ACI.txt
index 99099275e1383f16aca122e05e34b2330f4d06a3..40fa822217eaee8d0966491b10cdf7e0739a87ce 100644
--- a/ACI.txt
+++ b/ACI.txt
@@ -338,6 +338,28 @@ dn: cn=users,cn=accounts,dc=ipa,dc=example
aci: (targetfilter = "(objectclass=posixaccount)")(version 3.0;acl "permission:System: Remove Users";allow (delete) groupdn = "ldap:///cn=System: Remove Users,cn=permissions,cn=pbac,dc=ipa,dc=example";)
dn: cn=users,cn=accounts,dc=ipa,dc=example
aci: (targetattr = "krblastadminunlock || krbloginfailedcount || nsaccountlock")(targetfilter = "(objectclass=posixaccount)")(version 3.0;acl "permission:System: Unlock User";allow (write) groupdn = "ldap:///cn=System: Unlock User,cn=permissions,cn=pbac,dc=ipa,dc=example";)
+dn: dc=ipa,dc=example
+aci: (target = "ldap:///cn=vaults,cn=kra,dc=ipa,dc=example")(targetfilter = "(objectclass=ipaVault)")(version 3.0;acl "permission:System: Add Vaults";allow (add) groupdn = "ldap:///cn=System: Add Vaults,cn=permissions,cn=pbac,dc=ipa,dc=example";)
+dn: dc=ipa,dc=example
+aci: (target = "ldap:///cn=vaults,cn=kra,dc=ipa,dc=example")(targetfilter = "(objectclass=ipaVault)")(version 3.0;acl "permission:System: Delete Vaults";allow (delete) groupdn = "ldap:///cn=System: Delete Vaults,cn=permissions,cn=pbac,dc=ipa,dc=example";)
+dn: dc=ipa,dc=example
+aci: (targetattr = "member")(target = "ldap:///cn=vaults,cn=kra,dc=ipa,dc=example")(targetfilter = "(objectclass=ipaVault)")(version 3.0;acl "permission:System: Manage Vault Membership";allow (write) groupdn = "ldap:///cn=System: Manage Vault Membership,cn=permissions,cn=pbac,dc=ipa,dc=example";)
+dn: dc=ipa,dc=example
+aci: (targetattr = "owner")(target = "ldap:///cn=vaults,cn=kra,dc=ipa,dc=example")(targetfilter = "(objectclass=ipaVault)")(version 3.0;acl "permission:System: Manage Vault Ownership";allow (write) groupdn = "ldap:///cn=System: Manage Vault Ownership,cn=permissions,cn=pbac,dc=ipa,dc=example";)
+dn: dc=ipa,dc=example
+aci: (targetattr = "cn || description || ipavaultpublickey || ipavaultsalt || ipavaulttype || objectclass")(target = "ldap:///cn=vaults,cn=kra,dc=ipa,dc=example")(targetfilter = "(objectclass=ipaVault)")(version 3.0;acl "permission:System: Modify Vaults";allow (write) groupdn = "ldap:///cn=System: Modify Vaults,cn=permissions,cn=pbac,dc=ipa,dc=example";)
+dn: dc=ipa,dc=example
+aci: (targetattr = "cn || createtimestamp || description || entryusn || ipavaultpublickey || ipavaultsalt || ipavaulttype || member || memberhost || memberuser || modifytimestamp || objectclass || owner")(target = "ldap:///cn=vaults,cn=kra,dc=ipa,dc=example")(targetfilter = "(objectclass=ipaVault)")(version 3.0;acl "permission:System: Read Vaults";allow (compare,read,search) groupdn = "ldap:///cn=System: Read Vaults,cn=permissions,cn=pbac,dc=ipa,dc=example";)
+dn: dc=ipa,dc=example
+aci: (target = "ldap:///cn=vaults,cn=kra,dc=ipa,dc=example")(targetfilter = "(objectclass=ipaVaultContainer)")(version 3.0;acl "permission:System: Add Vault Containers";allow (add) groupdn = "ldap:///cn=System: Add Vault Containers,cn=permissions,cn=pbac,dc=ipa,dc=example";)
+dn: dc=ipa,dc=example
+aci: (target = "ldap:///cn=vaults,cn=kra,dc=ipa,dc=example")(targetfilter = "(objectclass=ipaVaultContainer)")(version 3.0;acl "permission:System: Delete Vault Containers";allow (delete) groupdn = "ldap:///cn=System: Delete Vault Containers,cn=permissions,cn=pbac,dc=ipa,dc=example";)
+dn: dc=ipa,dc=example
+aci: (targetattr = "owner")(target = "ldap:///cn=vaults,cn=kra,dc=ipa,dc=example")(targetfilter = "(objectclass=ipaVaultContainer)")(version 3.0;acl "permission:System: Manage Vault Container Ownership";allow (write) groupdn = "ldap:///cn=System: Manage Vault Container Ownership,cn=permissions,cn=pbac,dc=ipa,dc=example";)
+dn: dc=ipa,dc=example
+aci: (targetattr = "cn || description || objectclass")(target = "ldap:///cn=vaults,cn=kra,dc=ipa,dc=example")(targetfilter = "(objectclass=ipaVaultContainer)")(version 3.0;acl "permission:System: Modify Vault Containers";allow (write) groupdn = "ldap:///cn=System: Modify Vault Containers,cn=permissions,cn=pbac,dc=ipa,dc=example";)
+dn: dc=ipa,dc=example
+aci: (targetattr = "cn || createtimestamp || description || entryusn || modifytimestamp || objectclass || owner")(target = "ldap:///cn=vaults,cn=kra,dc=ipa,dc=example")(targetfilter = "(objectclass=ipaVaultContainer)")(version 3.0;acl "permission:System: Read Vault Containers";allow (compare,read,search) groupdn = "ldap:///cn=System: Read Vault Containers,cn=permissions,cn=pbac,dc=ipa,dc=example";)
dn: cn=ca_renewal,cn=ipa,cn=etc,dc=ipa,dc=example
aci: (target = "ldap:///cn=caSigningCert cert-pki-ca,cn=ca_renewal,cn=ipa,cn=etc,dc=ipa,dc=example")(targetfilter = "(objectclass=pkiuser)")(version 3.0;acl "permission:System: Add CA Certificate For Renewal";allow (add) groupdn = "ldap:///cn=System: Add CA Certificate For Renewal,cn=permissions,cn=pbac,dc=ipa,dc=example";)
dn: cn=certificates,cn=ipa,cn=etc,dc=ipa,dc=example
diff --git a/install/updates/40-delegation.update b/install/updates/40-delegation.update
index 8d4f6296cbed7fcc968c2193022cb50b488c8561..08906a663c818695b8af29449c6ce8fab2dfdbee 100644
--- a/install/updates/40-delegation.update
+++ b/install/updates/40-delegation.update
@@ -260,3 +260,11 @@ default:objectClass: groupofnames
default:objectClass: top
default:cn: CA Administrator
default:description: CA Administrator
+
+# Vault Administrators
+dn: cn=Vault Administrators,cn=privileges,cn=pbac,$SUFFIX
+default:objectClass: nestedgroup
+default:objectClass: groupofnames
+default:objectClass: top
+default:cn: Vault Administrators
+default:description: Vault Administrators
diff --git a/ipalib/plugins/vault.py b/ipalib/plugins/vault.py
index d9551c2f0cfc16973131c61db45bc606d2844fb6..1159a84d58eb152cccdd791c96a1c876754bfa7d 100644
--- a/ipalib/plugins/vault.py
+++ b/ipalib/plugins/vault.py
@@ -289,6 +289,7 @@ class vaultcontainer(LDAPObject):
object_name = _('vaultcontainer')
object_name_plural = _('vaultcontainers')
object_class = ['ipaVaultContainer']
+ permission_filter_objectclasses = ['ipaVaultContainer']
attribute_members = {
'owner': ['user', 'group', 'service'],
@@ -297,6 +298,48 @@ class vaultcontainer(LDAPObject):
label = _('Vault Containers')
label_singular = _('Vault Container')
+ managed_permissions = {
+ 'System: Read Vault Containers': {
+ 'ipapermlocation': api.env.basedn,
+ 'ipapermtarget': DN(api.env.container_vault, api.env.basedn),
+ 'ipapermright': {'read', 'search', 'compare'},
+ 'ipapermdefaultattr': {
+ 'objectclass', 'cn', 'description', 'owner',
+ },
+ 'default_privileges': {'Vault Administrators'},
+ },
+ 'System: Add Vault Containers': {
+ 'ipapermlocation': api.env.basedn,
+ 'ipapermtarget': DN(api.env.container_vault, api.env.basedn),
+ 'ipapermright': {'add'},
+ 'default_privileges': {'Vault Administrators'},
+ },
+ 'System: Delete Vault Containers': {
+ 'ipapermlocation': api.env.basedn,
+ 'ipapermtarget': DN(api.env.container_vault, api.env.basedn),
+ 'ipapermright': {'delete'},
+ 'default_privileges': {'Vault Administrators'},
+ },
+ 'System: Modify Vault Containers': {
+ 'ipapermlocation': api.env.basedn,
+ 'ipapermtarget': DN(api.env.container_vault, api.env.basedn),
+ 'ipapermright': {'write'},
+ 'ipapermdefaultattr': {
+ 'objectclass', 'cn', 'description',
+ },
+ 'default_privileges': {'Vault Administrators'},
+ },
+ 'System: Manage Vault Container Ownership': {
+ 'ipapermlocation': api.env.basedn,
+ 'ipapermtarget': DN(api.env.container_vault, api.env.basedn),
+ 'ipapermright': {'write'},
+ 'ipapermdefaultattr': {
+ 'owner',
+ },
+ 'default_privileges': {'Vault Administrators'},
+ },
+ }
+
takes_params = (
Str(
'owner_user?',
@@ -491,6 +534,7 @@ class vault(LDAPObject):
object_name_plural = _('vaults')
object_class = ['ipaVault']
+ permission_filter_objectclasses = ['ipaVault']
default_attributes = [
'cn',
'description',
@@ -513,6 +557,60 @@ class vault(LDAPObject):
label = _('Vaults')
label_singular = _('Vault')
+ managed_permissions = {
+ 'System: Read Vaults': {
+ 'ipapermlocation': api.env.basedn,
+ 'ipapermtarget': DN(api.env.container_vault, api.env.basedn),
+ 'ipapermright': {'read', 'search', 'compare'},
+ 'ipapermdefaultattr': {
+ 'objectclass', 'cn', 'description', 'ipavaulttype',
+ 'ipavaultsalt', 'ipavaultpublickey', 'owner', 'member',
+ 'memberuser', 'memberhost',
+ },
+ 'default_privileges': {'Vault Administrators'},
+ },
+ 'System: Add Vaults': {
+ 'ipapermlocation': api.env.basedn,
+ 'ipapermtarget': DN(api.env.container_vault, api.env.basedn),
+ 'ipapermright': {'add'},
+ 'default_privileges': {'Vault Administrators'},
+ },
+ 'System: Delete Vaults': {
+ 'ipapermlocation': api.env.basedn,
+ 'ipapermtarget': DN(api.env.container_vault, api.env.basedn),
+ 'ipapermright': {'delete'},
+ 'default_privileges': {'Vault Administrators'},
+ },
+ 'System: Modify Vaults': {
+ 'ipapermlocation': api.env.basedn,
+ 'ipapermtarget': DN(api.env.container_vault, api.env.basedn),
+ 'ipapermright': {'write'},
+ 'ipapermdefaultattr': {
+ 'objectclass', 'cn', 'description', 'ipavaulttype',
+ 'ipavaultsalt', 'ipavaultpublickey',
+ },
+ 'default_privileges': {'Vault Administrators'},
+ },
+ 'System: Manage Vault Ownership': {
+ 'ipapermlocation': api.env.basedn,
+ 'ipapermtarget': DN(api.env.container_vault, api.env.basedn),
+ 'ipapermright': {'write'},
+ 'ipapermdefaultattr': {
+ 'owner',
+ },
+ 'default_privileges': {'Vault Administrators'},
+ },
+ 'System: Manage Vault Membership': {
+ 'ipapermlocation': api.env.basedn,
+ 'ipapermtarget': DN(api.env.container_vault, api.env.basedn),
+ 'ipapermright': {'write'},
+ 'ipapermdefaultattr': {
+ 'member',
+ },
+ 'default_privileges': {'Vault Administrators'},
+ },
+ }
+
takes_params = (
Str(
'cn',
--
2.4.3