Note:
  • Allow Access to Session Management API must be enabled on an OAuth client to allow the client to access this session management API by user identifier.
  • Adapters must be configured with a Unique User Key Attribute, as described in Setting pseudonym and masking options.
  • The user_key specified in the session management API request must match the value of the Unique User Key Attribute determined at runtime.
  • If the Hash Unique User Key Value option is enabled in the Authentication Sessions section in Authentication > Policies > Sessions, the user identifier passed into the URL parameter user_key needs to be the hashed value. The hashed value will be visible in server and audit logs, and in session storage if Make Authentication Sessions Persistent is enabled.
  • This API is different than the other session management APIs in that it only returns currently valid sessions (status = HAS_VALID_SESSIONS). Revoked sessions (SESSION_REVOKED) or users without any sessions (NO_VALID_SESSIONS) will not be seen from this API.
  • The user_key parameter needs to be URL encoded (@ is encoded as %40) since the value appears as a query parameter in the URL.

Applications can query or revoke user sessions based on user identifiers. The bulk revocation capability provides a convenient way to expire server-side authentication sessions on a per-user basis if needed. When revoked and without valid credentials, such end-users will not be able to fulfill authentication requirements and access protected resources.

An OAuth client needs to obtain a user identifier and send it to the session management API in an HTTP GET or POST request. If the client is configured to obtain an access token, an ID token, or a User Info response, it could potentially get the user identifier that way. However, if the client is not configured to obtain one of these items, or if none of them delivers the applicable user identifier, the client can still use this endpoint by sending a user identifier. For example, an application for the help desk to query or revoke all authentication sessions for a given user falls into this category. In this example, the developer will build an application to prompt the help desk staff to provide a user identifier, which becomes the user_key parameter value, send a GET or POST request to the session management API endpoint, and display the result of the request.

The API returns information in JSON format about each session associated with the user, such as:

  • SRI
  • Status
  • Last activity time
  • Authentication sessions
    • Authentication Source
    • ID of the per-authentication source session information
    • Creation time
    • Idle and maximum timeout
Note:

The API response body includes only sessions that were configured with the authentication sessions capability described in Configuring authentication sessions.

An OAuth client can also send the user identifier to the session management API in an HTTP POST request to revoke the sessions.

The session management API works with sessions stored in persistent storage and across clustered nodes. For this API, the runtime API's audit log only records session revoke events.

Important:

OAuth clients must authenticate to the API using their configured client authentication method.

To configure PingFederate so that an OAuth client can use the session management API, allow the client to access the session management API, as described in Configuring OAuth clients

Session management API by user identifier endpoints

The session management API by user identifiers has one endpoint, which requires the user_key parameter.

The OpenID Provider configuration endpoint /.well-known/openid-configuration provides configuration information for OAuth clients to access the session management API endpoints. For more information, see OpenID Provider configuration endpoint.

Endpoint /pf-ws/rest/sessionMgmt/users/{user_key}

Use HTTP GET requests to get information about all sessions associated with the user specified by the user_key parameter.

Sample request:

GET /pf-ws/rest/sessionMgmt/users/john%40test.com-east HTTP/1.1

Sample response

{
     "sri": "A0heNjTF8NwY9MNNmC42IQGDgvw..tHPC",
     "status": "HAS_VALID_SESSIONS",
     "lastActivityTime": "2020-11-18T01:07:20.097Z",
     "authnSessions": [ // This section can include multiple sessions
         {
             "authnSource": {
                 "sourceType": "IDP_CONN",
                 "id": "XMiOW6GGUBNYGYjJdXUEN2jU3Dg",
                 "entityId": "CIAM.Google"
              },
              "id": "ba5a3d97afee5ef9450b710ff932680e3579dc7f",
              "creationTime": "2020-11-18T01:07:20.096Z",
              "idleTimeout": "2020-11-18T02:07:20.097Z",
              "maxTimeout": "2020-11-19T09:07:20.096Z"
         },
         {
              "authnSource": {
                  "sourceType": "ADAPTER",
                  "id": "CIAMHtml",
                  "adapterType": "HTML Form IdP Adapter"
              },
              "id": "7cbef5022be8d841f14a95ace8987cbb34c77a21",
              "creationTime": "2020-11-18T01:07:19.537Z",
              "idleTimeout": "2020-11-18T02:07:20.097Z",
              "maxTimeout": "2020-11-19T09:07:19.537Z"
         }
    ]
]

Endpoint /pf-ws/rest/sessionMgmt/users/{user_key}/revoke

Use HTTP POST requests to revoke all PingFederate runtime authentication sessions that are associated with the given user identifier user_key. After running this request, any revoked sessions will be logged with an event as "SRI_REVOKED" in the audit log.

Sample request:

POST /pf-ws/rest/sessionMgmt/users/john%40test.com-east/revoke HTTP/1.1
Host: www.example.com
X-XSRF-Header: PingFederate
Authorization: Basic YWNfY2xpZW50OmdPWDh0NEQ...h3ZjI=
Cookie: PF=K60mOoBlTvWcD4frFzcKF5

Return codes:

  • 200 OK: The request was successfully processed
  • 503 Service Unavailable: An error occurred while deleting stored sessions
Note:

You can optionally use the endpoints described in Session Management API by session identifiers if needed.