keycloak.authorization

Authorization module.

Submodules

Package Contents

Classes

Permission

Base permission class.

Policy

Base policy class.

Role

Authorization Role base class.

Authorization

Keycloak Authorization (policies, roles, scopes and resources).

class keycloak.authorization.Permission(name, type, logic, decision_strategy)[source]

Base permission class.

Consider this simple and very common permission:

A permission associates the object being protected with the policies that must be evaluated to determine whether access is granted.

X CAN DO Y ON RESOURCE Z

where

  • X represents one or more users, roles, or groups, or a combination of them. You can

    also use claims and context here.

  • Y represents an action to be performed, for example, write, view, and so on.

  • Z represents a protected resource, for example, “/accounts”.

https://keycloak.gitbooks.io/documentation/authorization_services/topics/permission/overview.html

__repr__(self)

Repr method.

__str__(self)

Str method.

property name(self)

Get name.

property type(self)

Get type.

property logic(self)

Get logic.

property decision_strategy(self)

Get decision strategy.

property resources(self)

Get resources.

property scopes(self)

Get scopes.

class keycloak.authorization.Policy(name, type, logic, decision_strategy)[source]

Base policy class.

A policy defines the conditions that must be satisfied to grant access to an object. Unlike permissions, you do not specify the object being protected but rather the conditions that must be satisfied for access to a given object (for example, resource, scope, or both). Policies are strongly related to the different access control mechanisms (ACMs) that you can use to protect your resources. With policies, you can implement strategies for attribute-based access control (ABAC), role-based access control (RBAC), context-based access control, or any combination of these.

https://keycloak.gitbooks.io/documentation/authorization_services/topics/policy/overview.html

__repr__(self)

Repr method.

__str__(self)

Str method.

property name(self)

Get name.

property type(self)

Get type.

property logic(self)

Get logic.

property decision_strategy(self)

Get decision strategy.

property roles(self)

Get roles.

property permissions(self)

Get permissions.

add_role(self, role)

Add keycloak role in policy.

Parameters

role – keycloak role.

Returns

add_permission(self, permission)

Add keycloak permission in policy.

Parameters

permission – keycloak permission.

Returns

class keycloak.authorization.Role(name, required=False)[source]

Authorization Role base class.

Roles identify a type or category of user. Admin, user, manager, and employee are all typical roles that may exist in an organization.

https://keycloak.gitbooks.io/documentation/server_admin/topics/roles.html

get_name(self)

Get name.

__eq__(self, other)

Eq method.

class keycloak.authorization.Authorization[source]

Keycloak Authorization (policies, roles, scopes and resources).

https://keycloak.gitbooks.io/documentation/authorization_services/index.html

property policies(self)[source]

Get policies.

load_config(self, data)[source]

Load policies, roles and permissions (scope/resources).

Parameters

data – keycloak authorization data (dict)

Returns

None