9.6.11. Container Handler Module

The container event handler module is used to perform actions on containers and their tokens in certain events. The container is either identified by the container serial from the request, response or from an identified token.

This way you can define workflows to automatically modify containers, delete or even create new containers. Additionally, the tokens in the container can be modified.

9.6.11.1. Possible Actions

9.6.11.1.1. create

A new container will be created. This new container can be assigned to a user, which was identified in the request. Additionally, a token identified in the request can be added to the container.

The administrator has to specify the containertype and can optionally specify a description.

9.6.11.1.2. delete

The container which was identified in the request will be deleted if all conditions are matched. The tokens in the container will not be deleted.

9.6.11.1.3. unassign

The container which was identified in the request will be unassign from all users if all conditions are matched. The tokens in the container will not be changed.

9.6.11.1.4. assign

The container which was identified in the request will be assigned to a user which was identified in the request. If the logged in user performing this action has the role ‘user’ it is always himself. The user is not assigned to the tokens in the container.

9.6.11.1.5. set states

The administrator can specify states that will be set on the container identified in the request. All other states will be removed.

The administrator can select the new states. If no state is selected, all states will be removed.

9.6.11.1.6. add states

The administrator can specify states that will be added to the container identified in the request. Previous states that are excluded by the new states will be removed. All other states that are not exclusive are kept.

The administrator can select the new states. If no state is selected, nothing happens.

9.6.11.1.7. set description

For the container identified in the request a new description will be set.

9.6.11.1.8. remove all tokens

All tokens will be removed from the container identified in the request.

9.6.11.1.9. set container info

For the container identified in the request the container info will be set. All previous entries will be removed.

It requires the specification of a key and optionally a value. If no value is defined, it is set to an empty string “”.

9.6.11.1.10. add container info

For the container identified in the request the container info will be added. Previous entries will be kept. Only if the given key already exists, an old entry will be overwritten.

It requires the specification of a key and a optionally value. If no value is defined, it is set to an empty string “”.

9.6.11.1.11. delete container info

For the container identified in the request the container info will be deleted. If a key is specified, only the entry of this key will be deleted. If no key is passed, all entries will be removed.

9.6.11.1.12. enable all tokens

For the container identified in the request all contained tokens will be enabled.

9.6.11.1.13. disable all tokens

For the container identified in the request all contained tokens will be disabled.

9.6.11.2. Code

This is the event handler module for container actions.

class privacyidea.lib.eventhandler.containerhandler.ACTION_TYPE[source]

Allowed actions

ADD_CONTAINER_INFO = 'add container info'
ADD_STATES = 'add states'
ASSIGN = 'assign'
DELETE = 'delete'
DELETE_CONTAINER_INFO = 'delete container info'
DISABLE_TOKENS = 'disable all tokens'
ENABLE_TOKENS = 'enable all tokens'
INIT = 'create'
REMOVE_TOKENS = 'remove all tokens'
SET_CONTAINER_INFO = 'set container info'
SET_DESCRIPTION = 'set description'
SET_STATES = 'set states'
UNASSIGN = 'unassign'
class privacyidea.lib.eventhandler.containerhandler.ContainerEventHandler[source]

This is the event handler for container actions.

property actions

This method returns a list of available actions, that are provided by this event handler. :return: dictionary of actions.

property allowed_positions

This returns the allowed positions of the event handler definition. This can be “post” or “pre” or both. :return: list of allowed positions

description = 'This event handler can trigger new actions on containers.'
do(action, options)[source]

Executes the defined action in the given event.

Parameters
  • action

  • options (dict) – Contains the flask parameters g, request, response and the handler_def configuration

Returns

True if the action was successful, False otherwise (missing information, e.g. serial, user)

identifier = 'Container'