keystone.assignment.core module

Main entry point into the Assignment service.

class keystone.assignment.core.Manager[source]

Bases: Manager

Default pivot point for the Assignment backend.

See keystone.common.manager.Manager for more details on how this dynamically calls the backend.

add_implied_roles(role_refs)[source]

Expand out implied roles.

The role_refs passed in have had all inheritance and group assignments expanded out. We now need to look at the role_id in each ref and see if it is a prior role for some implied roles. If it is, then we need to duplicate that ref, one for each implied role. We store the prior role in the indirect dict that is part of such a duplicated ref, so that a caller can determine where the assignment came from.

add_role_to_user_and_project(user_id, project_id, role_id)[source]
check_system_grant_for_group(group_id, role_id)[source]

Check if a group has a specific role on the system.

Parameters:
  • group_id – the ID of the group in the assignment

  • role_id – the ID of the system role in the assignment

Raises:

keystone.exception.RoleAssignmentNotFound – if the group doesn’t have a role assignment matching the role_id on the system

check_system_grant_for_user(user_id, role_id)[source]

Check if a user has a specific role on the system.

Parameters:
  • user_id – the ID of the user in the assignment

  • role_id – the ID of the system role in the assignment

Raises:

keystone.exception.RoleAssignmentNotFound – if the user doesn’t have a role assignment matching the role_id on the system

create_grant(role_id, user_id=None, group_id=None, domain_id=None, project_id=None, inherited_to_projects=False, initiator=None)[source]
create_system_grant_for_group(group_id, role_id)[source]

Grant a group a role on the system.

Parameters:
  • group_id – the ID of the group

  • role_id – the ID of the role to grant on the system

create_system_grant_for_user(user_id, role_id)[source]

Grant a user a role on the system.

Parameters:
  • user_id – the ID of the user

  • role_id – the ID of the role to grant on the system

delete_grant(role_id, user_id=None, group_id=None, domain_id=None, project_id=None, inherited_to_projects=False, initiator=None)[source]
delete_group_assignments(group_id)[source]
delete_system_grant_for_group(group_id, role_id)[source]

Remove a system grant from a group.

Parameters:
  • group_id – the ID of the group

  • role_id – the ID of the role to remove from the group on the system

Raises:

keystone.exception.RoleAssignmentNotFound – if the group doesn’t have a role assignment with role_id on the system

delete_system_grant_for_user(user_id, role_id)[source]

Remove a system grant from a user.

Parameters:
  • user_id – the ID of the user

  • role_id – the ID of the role to remove from the user on the system

Raises:

keystone.exception.RoleAssignmentNotFound – if the user doesn’t have a role assignment with role_id on the system

delete_user_assignments(user_id)[source]
driver_namespace = 'keystone.assignment'
get_grant(role_id, user_id=None, group_id=None, domain_id=None, project_id=None, inherited_to_projects=False)[source]
get_roles_for_groups(group_ids, project_id=None, domain_id=None)[source]

Get a list of roles for this group on domain and/or project.

get_roles_for_trustor_and_project(trustor_id, project_id)[source]

Get the roles associated with a trustor within given project.

This includes roles directly assigned to the trustor on the project, as well as those by virtue of group membership or inheritance, but it doesn’t include the domain roles.

Returns:

a list of role ids.

Raises:

keystone.exception.ProjectNotFound – If the project doesn’t exist.

get_roles_for_user_and_domain(user_id, domain_id)[source]

Get the roles associated with a user within given domain.

Returns:

a list of role ids.

Raises:

keystone.exception.DomainNotFound – If the domain doesn’t exist.

get_roles_for_user_and_project(user_id, project_id)[source]

Get the roles associated with a user within given project.

This includes roles directly assigned to the user on the project, as well as those by virtue of group membership or inheritance.

Returns:

a list of role ids.

Raises:

keystone.exception.ProjectNotFound – If the project doesn’t exist.

list_all_system_grants()[source]

Return a list of all system grants.

list_domains_for_groups(group_ids)[source]
list_domains_for_user(user_id)[source]
list_grants(user_id=None, group_id=None, domain_id=None, project_id=None, inherited_to_projects=False)[source]
list_projects_for_groups(group_ids)[source]
list_projects_for_user(user_id)[source]
list_role_assignments(role_id=None, user_id=None, group_id=None, system=None, domain_id=None, project_id=None, include_subtree=False, inherited=None, effective=None, include_names=False, source_from_group_ids=None, strip_domain_roles=True)[source]

List role assignments, honoring effective mode and provided filters.

Returns a list of role assignments, where their attributes match the provided filters (role_id, user_id, group_id, domain_id, project_id and inherited). If include_subtree is True, then assignments on all descendants of the project specified by project_id are also included. The inherited filter defaults to None, meaning to get both non-inherited and inherited role assignments.

If effective mode is specified, this means that rather than simply return the assignments that match the filters, any group or inheritance assignments will be expanded. Group assignments will become assignments for all the users in that group, and inherited assignments will be shown on the projects below the assignment point. Think of effective mode as being the list of assignments that actually affect a user, for example the roles that would be placed in a token.

If include_names is set to true the entities’ names are returned in addition to their id’s.

source_from_group_ids is a list of group IDs and, if specified, then only those assignments that are derived from membership of these groups are considered, and any such assignments will not be expanded into their user membership assignments. This is different to a group filter of the resulting list, instead being a restriction on which assignments should be considered before expansion of inheritance. This option is only used internally (i.e. it is not exposed at the API level) and is only supported in effective mode (since in regular mode there is no difference between this and a group filter, other than it is a list of groups).

In effective mode, any domain specific roles are usually stripped from the returned assignments (since such roles are not placed in tokens). This stripping can be disabled by specifying strip_domain_roles=False, which is useful for internal calls like trusts which need to examine the full set of roles.

list_system_grants_for_group(group_id)[source]

Return a list of roles the group has on the system.

Parameters:

group_id – the ID of the group

Returns:

a list of role assignments the group has system-wide

list_system_grants_for_user(user_id)[source]

Return a list of roles the user has on the system.

Parameters:

user_id – the ID of the user

Returns:

a list of role assignments the user has system-wide

list_user_ids_for_project(project_id)[source]
remove_role_from_user_and_project(user_id, project_id, role_id)[source]
class keystone.assignment.core.RoleManager[source]

Bases: Manager

Default pivot point for the Role backend.

create_implied_role(prior_role_id, implied_role_id)[source]
create_role(role_id, role, initiator=None)[source]
delete_implied_role(prior_role_id, implied_role_id)[source]
delete_role(role_id, initiator=None)[source]
driver_namespace = 'keystone.role'
get_role(role_id)[source]
get_unique_role_by_name(role_name, hints=None)[source]
list_roles(hints=None)[source]
update_role(role_id, role, initiator=None)[source]