RuntimeCustomClaim Class
Represents a custom claim validation configuration for Runtime JWT authorizers.
Custom claims allow you to validate additional fields in JWT tokens beyond the standard audience, client, and scope validations.
Example
ts
declare const userPool: cognito.UserPool;
declare const userPoolClient: cognito.UserPoolClient;
declare const anotherUserPoolClient: cognito.UserPoolClient;
const repository = new ecr.Repository(this, "TestRepository", {
repositoryName: "test-agent-runtime",
});
const agentRuntimeArtifact = agentcore.AgentRuntimeArtifact.fromEcrRepository(repository, "v1.0.0");
// Optional: Create custom claims for additional validation
const customClaims = [
agentcore.RuntimeCustomClaim.withStringValue('department', 'engineering'),
agentcore.RuntimeCustomClaim.withStringArrayValue('roles', ['admin'], agentcore.CustomClaimOperator.CONTAINS),
agentcore.RuntimeCustomClaim.withStringArrayValue('permissions', ['read', 'write'], agentcore.CustomClaimOperator.CONTAINS_ANY),
];
const runtime = new agentcore.Runtime(this, "MyAgentRuntime", {
runtimeName: "myAgent",
agentRuntimeArtifact: agentRuntimeArtifact,
authorizerConfiguration: agentcore.RuntimeAuthorizerConfiguration.usingCognito(
userPool, // User Pool (required)
[userPoolClient, anotherUserPoolClient], // User Pool Clients
["audience1"], // Allowed Audiences (optional)
["read", "write"], // Allowed Scopes (optional)
customClaims, // Custom claims (optional) - see Custom Claims Validation section
),
});
Methods
withStringArrayValue(name: string, values: string[], operator?: CustomClaimOperator): RuntimeCustomClaim // chainable@staticmethod def with_string_array_value(name: str, values: typing.List[str], operator: typing.Optional[CustomClaimOperator] = None) -> RuntimeCustomClaimpublic static RuntimeCustomClaim withStringArrayValue(String name, List<String> values, CustomClaimOperator operator)public static RuntimeCustomClaim WithStringArrayValue(string name, string[] values, CustomClaimOperator? operator = null)func WithStringArrayValue(Name *string, Values *[]*string, Operator CustomClaimOperator) RuntimeCustomClaimstatic#Create a custom claim with a string array value.
String array claims can use CONTAINS (default) or CONTAINS_ANY operator.
3 parameters · returns
Parameters
namenamenamenameName— The name of the claim in the JWT token.valuesvaluesvaluesvaluesValues— The array of string values to match.operatoroperatoroperatoroperatorOperator— The match operator (defaults to CONTAINS).
Returns: A RuntimeCustomClaim configured for string array validation
withStringValue(name: string, value: string): RuntimeCustomClaim // chainable@staticmethod def with_string_value(name: str, value: str) -> RuntimeCustomClaimpublic static RuntimeCustomClaim withStringValue(String name, String value)public static RuntimeCustomClaim WithStringValue(string name, string value)func WithStringValue(Name *string, Value *string) RuntimeCustomClaimstatic#Create a custom claim with a string value.
String claims must use the EQUALS operator.
2 parameters · returns
Parameters
namenamenamenameName— The name of the claim in the JWT token.valuevaluevaluevalueValue— The string value to match (must exactly equal).
Returns: A RuntimeCustomClaim configured for string validation