8.6.7. ResponseMangler Handler Module

The ResponseMangler is a special handler module, that can modify the response of an HTTP request. This way privacyIDEA can change the data sent back to the client, depending on certain conditions.

All actions take a JSON pointer, which looks like a path variable like /result/value. Possible Actions delete

This action simply deletes the given JSON pointer from the response.


All keys underneath a node are deleted as well. So if the event handler deletes /detail, the entries /detail/message and /detail/error will also be deleted.


You can use this to delete /detail/googleurl, /detail/oathurl and /detail/otpkey in a /token/init event to hide the created QR code from the helpdesk admin. This way the QR code could be used internally, but could be hidden from the administrator. set

This action is used to add additional pointers to the JSON response or to modify existing entries. Existing entries are overwritten.

This action takes the additional attributes type and value.

The value can be returned as a string, an integer or a boolean. Code

This is the event handler module that can mangle the JSON response. We can add or delete key or even subtrees in the JSON response of a request.

The key is identified by a JSON Pointer (see https://tools.ietf.org/html/rfc6901)

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

Allowed actions

DELETE = 'delete'
SET = 'set'
class privacyidea.lib.eventhandler.responsemangler.ResponseManglerEventHandler[source]

An Eventhandler needs to return a list of actions, which it can handle.

It also returns a list of allowed action and conditions

It returns an identifier, which can be used in the eventhandlig definitions

property actions

This method returns a dictionary of allowed actions and possible options in this handler module.


dict with actions

property allowed_positions

This returns the allowed positions of the event handler definition. The ResponseMangler can only be located at the “post” position


list of allowed positions

description = 'This event handler can mangle the JSON response.'
do(action, options=None)[source]

This method executes the defined action in the given event.

  • action

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


identifier = 'ResponseMangler'