---
title: AssignmentFilter
description: Configure AssignmentFilter in PingGateway to assign values to targets based on conditions, evaluated before a request or after a response is handled
component: pinggateway
version: 2024.11
page_id: pinggateway:reference:AssignmentFilter
canonical_url: https://docs.pingidentity.com/pinggateway/2026/reference/AssignmentFilter.html
llms_txt: https://docs.pingidentity.com/pinggateway/llms.txt
docs_for_agents: https://developer.pingidentity.com/build-with-ai/docs-for-agents.md
revdate: 2026-06-02T09:47:34Z
superseded_by: https://docs.pingidentity.com/pinggateway/2026/reference/AssignmentFilter.html
section_ids:
  AssignmentFilter-usage: Usage
  AssignmentFilter-properties: Properties
  AssignmentFilter-example: Examples
  AssignmentFilter-example-addinfo: Add info to a session
  AssignmentFilter-example-capturecred: Capture and store login credentials
  AssignmentFilter-moreinfo: More information
---

# AssignmentFilter

Verifies that a specified condition is met. If the condition is met or if no condition is specified, the value is assigned to the target. Values can be assigned before the request is handled and after the response is handled.

## Usage

```json
{
  "name": string,
  "type": "AssignmentFilter",
  "config": {
    "onRequest": [
      {
        "condition": runtime expression<boolean>,
        "target": lvalue-expression,
        "value": runtime expression
      }, ...
    ],
    "onResponse": [
      {
        "condition": runtime expression<boolean>,
        "target": lvalue-expression,
        "value": runtime expression
      }, ...
    ]
  }
}
```

## Properties

* `"onRequest"`: *array of [objects](preface.html#definition-object), optional*

  Defines a list of assignment bindings to evaluate before the request is handled.

* `"onResponse"`: *array of [objects](preface.html#definition-object), optional*

  Defines a list of assignment bindings to evaluate after the response is handled.

* `"condition"`: *runtime expression<[boolean](preface.html#definition-boolean)>, optional*

  If the expression evaluates `true`, the value is assigned to the target.

  Default: `${true}`

* `"target"`: *<[lvalue-expression](preface.html#definition-lvalue-expression)>, required*

  Expression that yields the target object whose value is to be set.

* `"value"`: *runtime expression<[object](preface.html#definition-object)> , optional*

  The value to be set in the target. The value can be a string, information from the context, or even a whole map of information.

## Examples

### Add info to a session

The following example assigns a value to a session to keep empty stateless session cookies:

```json
{
  "type": "AssignmentFilter",
  "config": {
    "onRequest": [{
      "target": "${session.authUsername}",
      "value": "I am root"
    }]
  }
}
```

### Capture and store login credentials

The following example captures credentials and stores them in the PingGateway session during a login request. Notice that the credentials are captured on the request but aren't marked as valid until the response returns a positive 302. The credentials could then be used to log a user in to a different application:

```json
{
  "name": "PortalLoginCaptureFilter",
  "type": "AssignmentFilter",
  "config": {
    "onRequest": [
      {
        "target": "${session.authUsername}",
        "value": "${request.queryParams['username'][0]}"
      },
      {
        "target": "${session.authPassword}",
        "value": "${request.queryParams['password'][0]}"
      },
      {
        "comment": "Authentication has not yet been confirmed.",
        "target": "${session.authConfirmed}",
        "value": "${false}"
      }
    ],
    "onResponse": [
      {
        "condition": "${response.status.code == 302}",
        "target": "${session.authConfirmed}",
        "value": "${true}"
      }
    ]
  }
}
```

## More information

[org.forgerock.openig.filter.AssignmentFilter](../_attachments/apidocs/org/forgerock/openig/filter/AssignmentFilter.html)
