RuntimeAuthorizerConfiguration Class
Abstract base class for runtime authorizer configurations.
Provides static factory methods to create different authentication types.
| Source | aws-bedrockagentcore/lib/runtime/inbound-auth/runtime-authorizer-configuration.ts |
|---|---|
| Type last changed |
Example
ts
const repository = new ecr.Repository(this, "TestRepository", {
repositoryName: "test-agent-runtime",
});
const agentRuntimeArtifact = agentcore.AgentRuntimeArtifact.fromEcrRepository(repository, "v1.0.0");
// String claim - validates that the claim exactly equals the specified value
// Uses EQUALS operator automatically
const departmentClaim = agentcore.RuntimeCustomClaim.withStringValue('department', 'engineering');
// String array claim with CONTAINS operator (default)
// Validates that the claim array contains a specific string value
// IMPORTANT: CONTAINS requires exactly one value in the array parameter
const rolesClaim = agentcore.RuntimeCustomClaim.withStringArrayValue('roles', ['admin']);
// String array claim with CONTAINS_ANY operator
// Validates that the claim array contains at least one of the specified values
// Use this when you want to check for multiple possible values
const permissionsClaim = agentcore.RuntimeCustomClaim.withStringArrayValue(
'permissions',
['read', 'write'],
agentcore.CustomClaimOperator.CONTAINS_ANY
);
// Use custom claims in authorizer configuration
const runtime = new agentcore.Runtime(this, "MyAgentRuntime", {
runtimeName: "myAgent",
agentRuntimeArtifact: agentRuntimeArtifact,
authorizerConfiguration: agentcore.RuntimeAuthorizerConfiguration.usingJWT(
"https://example.com/.well-known/openid-configuration",
["client1", "client2"],
["audience1"],
["read", "write"],
[departmentClaim, rolesClaim, permissionsClaim] // Custom claims
),
});
python
repository = ecr.Repository(self, "TestRepository",
repository_name="test-agent-runtime"
)
agent_runtime_artifact = agentcore.AgentRuntimeArtifact.from_ecr_repository(repository, "v1.0.0")
# String claim - validates that the claim exactly equals the specified value
# Uses EQUALS operator automatically
department_claim = agentcore.RuntimeCustomClaim.with_string_value("department", "engineering")
# String array claim with CONTAINS operator (default)
# Validates that the claim array contains a specific string value
# IMPORTANT: CONTAINS requires exactly one value in the array parameter
roles_claim = agentcore.RuntimeCustomClaim.with_string_array_value("roles", ["admin"])
# String array claim with CONTAINS_ANY operator
# Validates that the claim array contains at least one of the specified values
# Use this when you want to check for multiple possible values
permissions_claim = agentcore.RuntimeCustomClaim.with_string_array_value("permissions", ["read", "write"], agentcore.CustomClaimOperator.CONTAINS_ANY)
# Use custom claims in authorizer configuration
runtime = agentcore.Runtime(self, "MyAgentRuntime",
runtime_name="myAgent",
agent_runtime_artifact=agent_runtime_artifact,
authorizer_configuration=agentcore.RuntimeAuthorizerConfiguration.using_jwt("https://example.com/.well-known/openid-configuration", ["client1", "client2"], ["audience1"], ["read", "write"], [department_claim, roles_claim, permissions_claim])
)
java
Repository repository = Repository.Builder.create(this, "TestRepository")
.repositoryName("test-agent-runtime")
.build();
AgentRuntimeArtifact agentRuntimeArtifact = AgentRuntimeArtifact.fromEcrRepository(repository, "v1.0.0");
// String claim - validates that the claim exactly equals the specified value
// Uses EQUALS operator automatically
RuntimeCustomClaim departmentClaim = RuntimeCustomClaim.withStringValue("department", "engineering");
// String array claim with CONTAINS operator (default)
// Validates that the claim array contains a specific string value
// IMPORTANT: CONTAINS requires exactly one value in the array parameter
RuntimeCustomClaim rolesClaim = RuntimeCustomClaim.withStringArrayValue("roles", List.of("admin"));
// String array claim with CONTAINS_ANY operator
// Validates that the claim array contains at least one of the specified values
// Use this when you want to check for multiple possible values
RuntimeCustomClaim permissionsClaim = RuntimeCustomClaim.withStringArrayValue("permissions", List.of("read", "write"), CustomClaimOperator.CONTAINS_ANY);
// Use custom claims in authorizer configuration
Runtime runtime = Runtime.Builder.create(this, "MyAgentRuntime")
.runtimeName("myAgent")
.agentRuntimeArtifact(agentRuntimeArtifact)
.authorizerConfiguration(RuntimeAuthorizerConfiguration.usingJWT("https://example.com/.well-known/openid-configuration", List.of("client1", "client2"), List.of("audience1"), List.of("read", "write"), List.of(departmentClaim, rolesClaim, permissionsClaim)))
.build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
var repository = new Repository(this, "TestRepository", new RepositoryProps {
RepositoryName = "test-agent-runtime"
});
var agentRuntimeArtifact = AgentRuntimeArtifact.FromEcrRepository(repository, "v1.0.0");
// String claim - validates that the claim exactly equals the specified value
// Uses EQUALS operator automatically
var departmentClaim = RuntimeCustomClaim.WithStringValue("department", "engineering");
// String array claim with CONTAINS operator (default)
// Validates that the claim array contains a specific string value
// IMPORTANT: CONTAINS requires exactly one value in the array parameter
var rolesClaim = RuntimeCustomClaim.WithStringArrayValue("roles", new [] { "admin" });
// String array claim with CONTAINS_ANY operator
// Validates that the claim array contains at least one of the specified values
// Use this when you want to check for multiple possible values
var permissionsClaim = RuntimeCustomClaim.WithStringArrayValue("permissions", new [] { "read", "write" }, CustomClaimOperator.CONTAINS_ANY);
// Use custom claims in authorizer configuration
var runtime = new Runtime(this, "MyAgentRuntime", new RuntimeProps {
RuntimeName = "myAgent",
AgentRuntimeArtifact = agentRuntimeArtifact,
AuthorizerConfiguration = RuntimeAuthorizerConfiguration.UsingJWT("https://example.com/.well-known/openid-configuration", new [] { "client1", "client2" }, new [] { "audience1" }, new [] { "read", "write" }, new [] { departmentClaim, rolesClaim, permissionsClaim })
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
repository := ecr.NewRepository(this, jsii.String("TestRepository"), &RepositoryProps{
RepositoryName: jsii.String("test-agent-runtime"),
})
agentRuntimeArtifact := agentcore.AgentRuntimeArtifact_FromEcrRepository(repository, jsii.String("v1.0.0"))
// String claim - validates that the claim exactly equals the specified value
// Uses EQUALS operator automatically
departmentClaim := agentcore.RuntimeCustomClaim_WithStringValue(jsii.String("department"), jsii.String("engineering"))
// String array claim with CONTAINS operator (default)
// Validates that the claim array contains a specific string value
// IMPORTANT: CONTAINS requires exactly one value in the array parameter
rolesClaim := agentcore.RuntimeCustomClaim_WithStringArrayValue(jsii.String("roles"), []*string{
jsii.String("admin"),
})
// String array claim with CONTAINS_ANY operator
// Validates that the claim array contains at least one of the specified values
// Use this when you want to check for multiple possible values
permissionsClaim := agentcore.RuntimeCustomClaim_WithStringArrayValue(jsii.String("permissions"), []*string{
jsii.String("read"),
jsii.String("write"),
}, agentcore.CustomClaimOperator_CONTAINS_ANY)
// Use custom claims in authorizer configuration
runtime := agentcore.NewRuntime(this, jsii.String("MyAgentRuntime"), &RuntimeProps{
RuntimeName: jsii.String("myAgent"),
AgentRuntimeArtifact: agentRuntimeArtifact,
AuthorizerConfiguration: agentcore.RuntimeAuthorizerConfiguration_UsingJWT(jsii.String("https://example.com/.well-known/openid-configuration"), []*string{
jsii.String("client1"),
jsii.String("client2"),
}, []*string{
jsii.String("audience1"),
}, []*string{
jsii.String("read"),
jsii.String("write"),
}, []RuntimeCustomClaim{
departmentClaim,
rolesClaim,
permissionsClaim,
}),
})
Initializer
ts
new RuntimeAuthorizerConfiguration()
python
RuntimeAuthorizerConfiguration()
java
new RuntimeAuthorizerConfiguration()
csharp
new RuntimeAuthorizerConfiguration()
go
NewRuntimeAuthorizerConfiguration()
Methods
usingCognito(userPool: IUserPool, userPoolClients: IUserPoolClient[], allowedAudience?: string[], allowedScopes?: string[], customClaims?: RuntimeCustomClaim[]): RuntimeAuthorizerConfiguration // chainable@staticmethod def using_cognito(user_pool: IUserPool, user_pool_clients: typing.List[IUserPoolClient], allowed_audience: typing.Optional[typing.List[str]] = None, allowed_scopes: typing.Optional[typing.List[str]] = None, custom_claims: typing.Optional[typing.List[RuntimeCustomClaim]] = None) -> RuntimeAuthorizerConfigurationpublic static RuntimeAuthorizerConfiguration usingCognito(IUserPool userPool, List<IUserPoolClient> userPoolClients, List<String> allowedAudience, List<String> allowedScopes, List<RuntimeCustomClaim> customClaims)public static RuntimeAuthorizerConfiguration UsingCognito(IUserPool userPool, IUserPoolClient[] userPoolClients, string[]? allowedAudience = null, string[]? allowedScopes = null, RuntimeCustomClaim[]? customClaims = null)func UsingCognito(UserPool IUserPool, UserPoolClients *[]IUserPoolClient, AllowedAudience *[]*string, AllowedScopes *[]*string, CustomClaims *[]RuntimeCustomClaim) RuntimeAuthorizerConfiguration static #Use AWS Cognito User Pool authentication.
Validates Cognito-issued JWT tokens.
5 parameters · returns
Parameters
userPooluser_pooluserPooluserPoolUserPool— The Cognito User Pool.userPoolClientsuser_pool_clientsuserPoolClientsuserPoolClientsUserPoolClients— The Cognito User Pool App Clients.allowedAudienceallowed_audienceallowedAudienceallowedAudienceAllowedAudience— Optional array of allowed audiences.allowedScopesallowed_scopesallowedScopesallowedScopesAllowedScopes— Optional array of allowed scopes.customClaimscustom_claimscustomClaimscustomClaimsCustomClaims— Optional array of custom claim validations.
Returns: RuntimeAuthorizerConfiguration for Cognito authentication
usingIAM(): RuntimeAuthorizerConfiguration // chainable@staticmethod def using_iam() -> RuntimeAuthorizerConfigurationpublic static RuntimeAuthorizerConfiguration usingIAM()public static RuntimeAuthorizerConfiguration UsingIAM()func UsingIAM() RuntimeAuthorizerConfiguration static #Use IAM authentication (default).
Requires AWS credentials to sign requests using SigV4.
returns
Returns: RuntimeAuthorizerConfiguration for IAM authentication
usingJWT(discoveryUrl: string, allowedClients?: string[], allowedAudience?: string[], allowedScopes?: string[], customClaims?: RuntimeCustomClaim[]): RuntimeAuthorizerConfiguration // chainable@staticmethod def using_jwt(discovery_url: str, allowed_clients: typing.Optional[typing.List[str]] = None, allowed_audience: typing.Optional[typing.List[str]] = None, allowed_scopes: typing.Optional[typing.List[str]] = None, custom_claims: typing.Optional[typing.List[RuntimeCustomClaim]] = None) -> RuntimeAuthorizerConfigurationpublic static RuntimeAuthorizerConfiguration usingJWT(String discoveryUrl, List<String> allowedClients, List<String> allowedAudience, List<String> allowedScopes, List<RuntimeCustomClaim> customClaims)public static RuntimeAuthorizerConfiguration UsingJWT(string discoveryUrl, string[]? allowedClients = null, string[]? allowedAudience = null, string[]? allowedScopes = null, RuntimeCustomClaim[]? customClaims = null)func UsingJWT(DiscoveryUrl *string, AllowedClients *[]*string, AllowedAudience *[]*string, AllowedScopes *[]*string, CustomClaims *[]RuntimeCustomClaim) RuntimeAuthorizerConfiguration static #Use custom JWT authentication.
Validates JWT tokens against the specified OIDC provider.
5 parameters · returns
Parameters
discoveryUrldiscovery_urldiscoveryUrldiscoveryUrlDiscoveryUrl— The OIDC discovery URL (must end with /.well-known/openid-configuration).allowedClientsallowed_clientsallowedClientsallowedClientsAllowedClients— Optional array of allowed client IDs.allowedAudienceallowed_audienceallowedAudienceallowedAudienceAllowedAudience— Optional array of allowed audiences.allowedScopesallowed_scopesallowedScopesallowedScopesAllowedScopes— Optional array of allowed scopes.customClaimscustom_claimscustomClaimscustomClaimsCustomClaims— Optional array of custom claim validations.
Returns: RuntimeAuthorizerConfiguration for JWT authentication
usingOAuth(discoveryUrl: string, clientId: string, allowedAudience?: string[], allowedScopes?: string[], customClaims?: RuntimeCustomClaim[]): RuntimeAuthorizerConfiguration // chainable@staticmethod def using_o_auth(discovery_url: str, client_id: str, allowed_audience: typing.Optional[typing.List[str]] = None, allowed_scopes: typing.Optional[typing.List[str]] = None, custom_claims: typing.Optional[typing.List[RuntimeCustomClaim]] = None) -> RuntimeAuthorizerConfigurationpublic static RuntimeAuthorizerConfiguration usingOAuth(String discoveryUrl, String clientId, List<String> allowedAudience, List<String> allowedScopes, List<RuntimeCustomClaim> customClaims)public static RuntimeAuthorizerConfiguration UsingOAuth(string discoveryUrl, string clientId, string[]? allowedAudience = null, string[]? allowedScopes = null, RuntimeCustomClaim[]? customClaims = null)func UsingOAuth(DiscoveryUrl *string, ClientId *string, AllowedAudience *[]*string, AllowedScopes *[]*string, CustomClaims *[]RuntimeCustomClaim) RuntimeAuthorizerConfiguration static #Use OAuth 2.0 authentication. Supports various OAuth providers.
5 parameters · returns
Parameters
discoveryUrldiscovery_urldiscoveryUrldiscoveryUrlDiscoveryUrl— The OIDC discovery URL (must end with /.well-known/openid-configuration).clientIdclient_idclientIdclientIdClientId— OAuth client ID.allowedAudienceallowed_audienceallowedAudienceallowedAudienceAllowedAudience— Optional array of allowed audiences.allowedScopesallowed_scopesallowedScopesallowedScopesAllowedScopes— Optional array of allowed scopes.customClaimscustom_claimscustomClaimscustomClaimsCustomClaims— Optional array of custom claim validations.
Returns: RuntimeAuthorizerConfiguration for OAuth authentication