Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions infra/bin/infra.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ if (config.stacks?.agent) {
defaultChatModelId,
defaultCreateModelId,
allowedModels,
mcpCustomScope: authStack.mcpCustomScope,
});
}
}
10 changes: 7 additions & 3 deletions infra/lib/web-ui-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ interface WebUiStackProps extends cdk.StackProps {
defaultCreateModelId: string;
/** Allowed models with resolved display metadata. */
allowedModels: Array<{ modelId: string; displayName: string; description?: string }>;
/** Custom OAuth scope for MCP access (e.g. `sdpm-mcp/invoke`). */
mcpCustomScope?: string;
}

export class WebUiStack extends cdk.Stack {
Expand Down Expand Up @@ -403,7 +405,7 @@ function handler(event) {
redirect_uri: "${SiteUrl}",
post_logout_redirect_uri: "${SiteUrl}",
response_type: "code",
scope: "openid profile email",
scope: "openid profile email${McpScope}",
automaticSilentRenew: true,
agentRuntimeArn: "${AgentRuntimeArn}",
apiBaseUrl: "${ApiBaseUrl}",
Expand All @@ -414,6 +416,7 @@ function handler(event) {
SiteUrl: this.siteUrl,
AgentRuntimeArn: props.agentRuntimeArn,
ApiBaseUrl: api.url,
McpScope: props.mcpCustomScope ? ` ${props.mcpCustomScope}` : "",
});

const awsExports = new cr.AwsCustomResource(this, "WriteAwsExports", {
Expand Down Expand Up @@ -446,6 +449,7 @@ function handler(event) {
awsExports.node.addDependency(deployment);

// --- Add Amazon CloudFront URL to Amazon Cognito callback/logout URLs ---
const oauthScopes = ["openid", "profile", "email", ...(props.mcpCustomScope ? [props.mcpCustomScope] : [])];
new cr.AwsCustomResource(this, "UpdateCognitoCallbackUrls", {
onCreate: {
service: "CognitoIdentityServiceProvider",
Expand All @@ -455,7 +459,7 @@ function handler(event) {
ClientId: props.userPoolClient.userPoolClientId,
SupportedIdentityProviders: ["COGNITO"],
AllowedOAuthFlows: ["code"],
AllowedOAuthScopes: ["openid", "profile", "email"],
AllowedOAuthScopes: oauthScopes,
AllowedOAuthFlowsUserPoolClient: true,
CallbackURLs: ["http://localhost:3000", this.siteUrl],
LogoutURLs: ["http://localhost:3000", this.siteUrl],
Expand All @@ -475,7 +479,7 @@ function handler(event) {
ClientId: props.userPoolClient.userPoolClientId,
SupportedIdentityProviders: ["COGNITO"],
AllowedOAuthFlows: ["code"],
AllowedOAuthScopes: ["openid", "profile", "email"],
AllowedOAuthScopes: oauthScopes,
AllowedOAuthFlowsUserPoolClient: true,
CallbackURLs: ["http://localhost:3000", this.siteUrl],
LogoutURLs: ["http://localhost:3000", this.siteUrl],
Expand Down
Loading