Skip to content
v2.278.0

CustomClaimOperator Enum ​

Custom claim match operator.

Shared by Runtime and Gateway custom claim implementations.

Example ​

ts
declare const userPool: cognito.UserPool;
declare const userPoolClient: cognito.UserPoolClient;

// Optional: Create custom claims (CustomClaimOperator and GatewayCustomClaim from agentcore)
const customClaims = [
  agentcore.GatewayCustomClaim.withStringValue('department', 'engineering'),
  agentcore.GatewayCustomClaim.withStringArrayValue('roles', ['admin'], agentcore.CustomClaimOperator.CONTAINS),
  agentcore.GatewayCustomClaim.withStringArrayValue('permissions', ['read', 'write'], agentcore.CustomClaimOperator.CONTAINS_ANY),
];

const gateway = new agentcore.Gateway(this, "MyGateway", {
  gatewayName: "my-gateway",
  authorizerConfiguration: agentcore.GatewayAuthorizer.usingCognito({
    userPool: userPool,
    allowedClients: [userPoolClient],
    allowedAudiences: ["audience1"],
    allowedScopes: ["read", "write"],
    customClaims: customClaims, // Optional custom claims
  }),
});
python
# user_pool: cognito.UserPool
# user_pool_client: cognito.UserPoolClient


# Optional: Create custom claims (CustomClaimOperator and GatewayCustomClaim from agentcore)
custom_claims = [
    agentcore.GatewayCustomClaim.with_string_value("department", "engineering"),
    agentcore.GatewayCustomClaim.with_string_array_value("roles", ["admin"], agentcore.CustomClaimOperator.CONTAINS),
    agentcore.GatewayCustomClaim.with_string_array_value("permissions", ["read", "write"], agentcore.CustomClaimOperator.CONTAINS_ANY)
]

gateway = agentcore.Gateway(self, "MyGateway",
    gateway_name="my-gateway",
    authorizer_configuration=agentcore.GatewayAuthorizer.using_cognito(
        user_pool=user_pool,
        allowed_clients=[user_pool_client],
        allowed_audiences=["audience1"],
        allowed_scopes=["read", "write"],
        custom_claims=custom_claims
    )
)
java
UserPool userPool;
UserPoolClient userPoolClient;


// Optional: Create custom claims (CustomClaimOperator and GatewayCustomClaim from agentcore)
GatewayCustomClaim[] customClaims = List.of(GatewayCustomClaim.withStringValue("department", "engineering"), GatewayCustomClaim.withStringArrayValue("roles", List.of("admin"), CustomClaimOperator.CONTAINS), GatewayCustomClaim.withStringArrayValue("permissions", List.of("read", "write"), CustomClaimOperator.CONTAINS_ANY));

Gateway gateway = Gateway.Builder.create(this, "MyGateway")
        .gatewayName("my-gateway")
        .authorizerConfiguration(GatewayAuthorizer.usingCognito(CognitoAuthorizerProps.builder()
                .userPool(userPool)
                .allowedClients(List.of(userPoolClient))
                .allowedAudiences(List.of("audience1"))
                .allowedScopes(List.of("read", "write"))
                .customClaims(customClaims)
                .build()))
        .build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
UserPool userPool;
UserPoolClient userPoolClient;


// Optional: Create custom claims (CustomClaimOperator and GatewayCustomClaim from agentcore)
var customClaims = new [] { GatewayCustomClaim.WithStringValue("department", "engineering"), GatewayCustomClaim.WithStringArrayValue("roles", new [] { "admin" }, CustomClaimOperator.CONTAINS), GatewayCustomClaim.WithStringArrayValue("permissions", new [] { "read", "write" }, CustomClaimOperator.CONTAINS_ANY) };

var gateway = new Gateway(this, "MyGateway", new GatewayProps {
    GatewayName = "my-gateway",
    AuthorizerConfiguration = GatewayAuthorizer.UsingCognito(new CognitoAuthorizerProps {
        UserPool = userPool,
        AllowedClients = new [] { userPoolClient },
        AllowedAudiences = new [] { "audience1" },
        AllowedScopes = new [] { "read", "write" },
        CustomClaims = customClaims
    })
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var userPool UserPool
var userPoolClient UserPoolClient


// Optional: Create custom claims (CustomClaimOperator and GatewayCustomClaim from agentcore)
customClaims := []GatewayCustomClaim{
	agentcore.GatewayCustomClaim_WithStringValue(jsii.String("department"), jsii.String("engineering")),
	agentcore.GatewayCustomClaim_WithStringArrayValue(jsii.String("roles"), []*string{
		jsii.String("admin"),
	}, agentcore.CustomClaimOperator_CONTAINS),
	agentcore.GatewayCustomClaim_WithStringArrayValue(jsii.String("permissions"), []*string{
		jsii.String("read"),
		jsii.String("write"),
	}, agentcore.CustomClaimOperator_CONTAINS_ANY),
}

gateway := agentcore.NewGateway(this, jsii.String("MyGateway"), &GatewayProps{
	GatewayName: jsii.String("my-gateway"),
	AuthorizerConfiguration: agentcore.GatewayAuthorizer_UsingCognito(&CognitoAuthorizerProps{
		UserPool: userPool,
		AllowedClients: []IUserPoolClient{
			userPoolClient,
		},
		AllowedAudiences: []*string{
			jsii.String("audience1"),
		},
		AllowedScopes: []*string{
			jsii.String("read"),
			jsii.String("write"),
		},
		CustomClaims: customClaims,
	}),
})

Members ​

MemberDescription
EQUALSEquals operator - used for STRING type claims.
CONTAINSContains operator - used for STRING_ARRAY type claims.
CONTAINS_ANYContainsAny operator - used for STRING_ARRAY type claims.