SessionAttr.create - REST API

Overview

Creates a new session attribute, optionally encrypting it before it is saved in the database. It is also possible to set expiry for an attribute, upon reaching of which the attribute will be no longer available.

An exception is raised if an attribute of a given name already exists - use set if an update should be issued instead of reporting an exception.

Unlike user attributes, session attributes are specific to a single user session and if a user logs in multiple times, each session will have its own set of attributes.

Attribute names and other metadata may be stored in server logs. Values are never saved to logs.

While the call's Python equivalent has two versions, one for individual and the other for multiple attributes, with REST there is a single endpoint to cover both cases. Yet, just like in the Python call, it is more efficient to create multiple attributes in one REST call instead of repeatedly creating individual ones.

  • HTTP method: POST
  • URL path: /zato/sso/session/attr

Request

NameDatatypeOptionalNotes
current_uststring---Current user's session token (UST)
target_uststring---Target session's UST, the one that is being manipulated (may be the same as current_ust)
current_appstring---Name of application that the call is attempted from
namestringYesIf a single attribute is to be created, the attribute's name
valuestringYesIf a single attribute is to be created, the attribute's value
datalistYesIf multiple attributes are to be created, a list of dictionaries, each describing an individual attribute, like in the create_many Python API
encryptboolYesShould the attribute's value be encrypted before it is saved to the database. Defaults to False.
expirationintYesAfter how many seconds from current time the attribute should expire. By default it will never expire.

Response

NameDatatypeOptionalNotes
cidstring---Correlation ID assigned to request
statusstring---Overall status code
sub_statuslistYesReturned only if status is not "ok", a list of error or warning codes

Usage

$ curl -XPOST localhost:17010/zato/sso/session/attr -d '
  {
    "current_ust": "gAAAAABavk-65BuvKI0JF...",
    "target_ust":  "gAAAAABavk-65BuKI0JFP...",
    "current_app": "CRM",
    "name": "my-rest-attribute",
    "value": "my-rest-value",
    "encrypt": true,
    "expiration": 3600
  }
  '

  {
    "status": "ok",
    "cid": "01513a304ef4409ed2a6caf3"
  }