diff --git a/packages/amazonq/.changes/next-release/Bug Fix-71c6bbc1-67ae-4318-a7f0-c594e097ebc4.json b/packages/amazonq/.changes/next-release/Bug Fix-71c6bbc1-67ae-4318-a7f0-c594e097ebc4.json new file mode 100644 index 00000000000..e0c15b7f2dc --- /dev/null +++ b/packages/amazonq/.changes/next-release/Bug Fix-71c6bbc1-67ae-4318-a7f0-c594e097ebc4.json @@ -0,0 +1,4 @@ +{ + "type": "Bug Fix", + "description": "Auth: Valid StartURL not accepted at login" +} diff --git a/packages/core/src/auth/sso/constants.ts b/packages/core/src/auth/sso/constants.ts index 4b0e781ceaa..0e6bb082d7e 100644 --- a/packages/core/src/auth/sso/constants.ts +++ b/packages/core/src/auth/sso/constants.ts @@ -11,8 +11,15 @@ export const builderIdStartUrl = 'https://view.awsapps.com/start' export const internalStartUrl = 'https://amzn.awsapps.com/start' +/** + * Doc: https://docs.aws.amazon.com/singlesignon/latest/userguide/howtochangeURL.html + */ export const ssoUrlFormatRegex = /^(https?:\/\/(.+)\.awsapps\.com\/start|https?:\/\/identitycenter\.amazonaws\.com\/ssoins-[\da-zA-Z]{16})\/?$/ -export const ssoUrlFormatMessage = - 'URLs must start with http:// or https://. Example: https://d-xxxxxxxxxx.awsapps.com/start' +/** + * It is possible for a start url to be a completely custom url that redirects to something that matches the format + * below, so this message is only a warning. + */ +export const ssoUrlFormatMessage = 'URL possibly invalid. Expected format: https://xxxxxxxxxx.awsapps.com/start' +export const urlInvalidFormatMessage = 'URL format invalid. Expected format: https://xxxxxxxxxx.com/yyyy' diff --git a/packages/core/src/login/webview/vue/backend.ts b/packages/core/src/login/webview/vue/backend.ts index 0c1cbdaebc7..ed467175334 100644 --- a/packages/core/src/login/webview/vue/backend.ts +++ b/packages/core/src/login/webview/vue/backend.ts @@ -31,6 +31,7 @@ import { AuthEnabledFeatures, AuthError, AuthFlowState, AuthUiClick, userCancell import { DevSettings } from '../../../shared/settings' import { AuthSSOServer } from '../../../auth/sso/server' import { getLogger } from '../../../shared/logger/logger' +import { isValidUrl } from '../../../shared/utilities/uriUtils' export abstract class CommonAuthWebview extends VueWebview { private readonly className = 'CommonAuthWebview' @@ -276,4 +277,8 @@ export abstract class CommonAuthWebview extends VueWebview { cancelAuthFlow() { AuthSSOServer.lastInstance?.cancelCurrentFlow() } + + validateUrl(url: string) { + return isValidUrl(url) + } } diff --git a/packages/core/src/login/webview/vue/login.vue b/packages/core/src/login/webview/vue/login.vue index f15848a9069..4c9f65a2f6a 100644 --- a/packages/core/src/login/webview/vue/login.vue +++ b/packages/core/src/login/webview/vue/login.vue @@ -193,6 +193,7 @@ @keydown.enter="handleContinueClick()" />

{{ startUrlError }}

+

{{ startUrlWarning }}

Region
AWS Region that hosts identity directory