Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
# Authors: # Rob Crittenden <rcritten@redhat.com> # # Copyright (C) 2010 Red Hat # see file 'COPYING' for use and warranty information # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>.
Permissions
A permission enables fine-grained delegation of rights. A permission is a human-readable form of a 389-ds Access Control Rule, or instruction (ACI). A permission grants the right to perform a specific task such as adding a user, modifying a group, etc.
A permission may not contain other permissions.
* A permission grants access to read, write, add or delete. * A privilege combines similar permissions (for example all the permissions needed to add a user). * A role grants a set of privileges to users, groups, hosts or hostgroups.
A permission is made up of a number of different parts:
1. The name of the permission. 2. The target of the permission. 3. The rights granted by the permission.
Rights define what operations are allowed, and may be one or more of the following: 1. write - write one or more attributes 2. read - read one or more attributes 3. add - add a new entry to the tree 4. delete - delete an existing entry 5. all - all permissions are granted
Read permission is granted for most attributes by default so the read permission is not expected to be used very often.
Note the distinction between attributes and entries. The permissions are independent, so being able to add a user does not mean that the user will be editable.
There are a number of allowed targets: 1. type: a type of object (user, group, etc). 2. memberof: a member of a group or hostgroup 3. filter: an LDAP filter 4. subtree: an LDAP filter specifying part of the LDAP DIT. This is a super-set of the "type" target. 5. targetgroup: grant access to modify a specific group (such as granting the rights to manage group membership)
EXAMPLES:
Add a permission that grants the creation of users: ipa permission-add --type=user --permissions=add "Add Users"
Add a permission that grants the ability to manage group membership: ipa permission-add --attrs=member --permissions=write --type=group "Manage Group Members" """)
Str('ipapermissiontype', label=_('Permission Type'), ), Str('aci', label=_('ACI'), ), )
""" Permission object. """ 'memberindirect', 'ipapermissiontype', ] 'filter', 'subtree', 'targetgroup', 'memberof', ] 'member': ['privilege'], }
Str('cn', cli_name='name', label=_('Permission name'), primary_key=True, pattern='^[-_ a-zA-Z0-9]+$', pattern_errmsg="May only contain letters, numbers, -, _, and space", ), Str('permissions+', cli_name='permissions', label=_('Permissions'), doc=_('Comma-separated list of permissions to grant ' \ '(read, write, add, delete, all)'), csv=True, ), Str('attrs*', cli_name='attrs', label=_('Attributes'), doc=_('Comma-separated list of attributes'), csv=True, normalizer=lambda value: value.lower(), flags=('ask_create', 'ask_update'), ), StrEnum('type?', cli_name='type', label=_('Type'), doc=_('Type of IPA object (user, group, host, hostgroup, service, netgroup, dns)'), values=(u'user', u'group', u'host', u'service', u'hostgroup', u'netgroup', u'dnsrecord',), flags=('ask_create', 'ask_update'), ), Str('memberof?', cli_name='memberof', label=_('Member of group'), # FIXME: Does this label make sense? doc=_('Target members of a group'), flags=('ask_create', 'ask_update'), ), Str('filter?', cli_name='filter', label=_('Filter'), doc=_('Legal LDAP filter (e.g. ou=Engineering)'), flags=('ask_create', 'ask_update'), ), Str('subtree?', cli_name='subtree', label=_('Subtree'), doc=_('Subtree to apply permissions to'), flags=('ask_create', 'ask_update'), ), Str('targetgroup?', cli_name='targetgroup', label=_('Target group'), doc=_('User group to apply permissions to'), flags=('ask_create', 'ask_update'), ), )
# Don't allow SYSTEM permissions to be modified or removed if 'SYSTEM' in entry_attrs['ipapermissiontype']: return False
# Test the ACI before going any further
# Clear the aci attributes out of the permission entry
# Now actually add the aci. except errors.InvalidSyntax, e: # A syntax error slipped past our attempt at validation, clean up self.api.Command.permission_del(keys[-1]) raise e except Exception, e: # Something bad happened, clean up as much as we can and return # that error try: self.api.Command.permission_del(keys[-1]) except Exception, ignore: pass try: self.api.Command.aci_del(keys[-1], aciprefix=ACI_PREFIX) except Exception, ignore: pass raise e
raise errors.ACIError(info='A SYSTEM permission may not be removed') # remove permission even when the underlying ACI is missing except errors.NotFound: pass
raise errors.ACIError(info='A SYSTEM permission may not be modified')
# check if permission is in LDAP dn, attrs_list, normalize=self.obj.normalize_dn ) except errors.NotFound: self.obj.handle_not_found(*keys)
# when renaming permission, check if the target permission does not # exists already. Then, make changes to underlying ACI new_dn, attrs_list, normalize=self.obj.normalize_dn ) else:
# If there are no options left we don't need to do anything to the # underlying ACI.
# Clear the aci attributes out of the permission entry
# Clear the aci attributes out of the permission entry raise exc
# rename the underlying ACI after the change to permission
permission=options['rename'])
newname=options['rename'], newprefix=ACI_PREFIX)
'%(count)d permission matched', '%(count)d permissions matched', 0 )
# copy information from respective ACI to permission entry except errors.NotFound: self.debug('ACI not found for %s' % attrs['cn'][0])
# Now find all the ACIs that match. Once we find them, add any that # aren't already in the list along with their permission info.
# permission ACI attribute is needed except: pass
permission = self.api.Command.permission_show(aci['permission'], **options)['result'] dn = permission['dn'] del permission['dn'] if (dn, permission) not in entries: entries.append((dn, permission))
# The ACI attributes are just broken-out components of aci so # the rights should all match it. for attr in self.obj.aci_attributes: entry_attrs['attributelevelrights'][attr] = entry_attrs['attributelevelrights']['aci']
""" Add members to a permission. """
""" Remove members from a permission. """
|