Event Handler

The following event handlers are known to privacyIDEA

class privacyidea.lib.event.EventConfiguration[source]

This class is supposed to contain the event handling configuration during the Request. The currently defined events are fetched from the request-local config object.

property events

Shortcut for retrieving the currently defined event handlers from the request-local config object.


Return the reduced list with the given eventid. This list should only have one element.


eventid (int or None) – id of the event


list with one element

get_handled_events(eventname, position='post')[source]

Return a list of the event handling definitions for the given eventname and the given position.

  • eventname – The name of the event

  • position – the position of the event definition



Delete the event configuration with this given ID. :param event_id: The database ID of the event. :type event_id: int :return:

privacyidea.lib.event.enable_event(event_id, enable=True)[source]

Enable or disable the event

  • event_id (int) – ID of the event

  • enable (bool) – enable or disable the event


class privacyidea.lib.event.event(eventname, request, g)[source]

This is the event decorator that calls the event handler in the handler module. This event decorator can be used at any API call


Export given or all event configuration


Return an event handler object based on the Name of the event handler class


handlername – The identifier of the Handler Class


privacyidea.lib.event.import_event(data, name=None)[source]

Import policy configuration

privacyidea.lib.event.set_event(name=None, event=None, handlermodule=None, action=None, conditions=None, ordering=0, options=None, id=None, active=True, position='post')[source]

Set an event handling configuration. This writes an entry to the database eventhandler.

  • name – The name of the event definition

  • event (basestring) – The name of the event to react on. Can be a single event or a comma separated list.

  • handlermodule (basestring) – The identifier of the event handler module. This is an identifier string like “UserNotification”

  • action (basestring) – The action to perform. This is an action defined by the handler module

  • conditions (dict) – A condition. Only if this condition is met, the action is performed.

  • ordering (integer) – An optional ordering of the event definitions.

  • options (dict) – Additional options, that are needed as parameters for the action

  • id (int) – The DB id of the event. If the id is given, the event is updated. Otherwise, a new entry is generated.

  • position (basestring) – The position of the event handler being “post” or “pre”


The id of the event.