|
5 | 5 | import * as vscode from 'vscode'
|
6 | 6 | import { Credentials } from '@aws-sdk/types'
|
7 | 7 | import { Mutable } from '../shared/utilities/tsUtils'
|
8 |
| -import { builderIdStartUrl, SsoToken } from './sso/model' |
| 8 | +import { builderIdStartUrl, SsoToken, truncateStartUrl } from './sso/model' |
9 | 9 | import { SsoClient } from './sso/clients'
|
10 | 10 | import { CredentialsProviderManager } from './providers/credentialsProviderManager'
|
11 | 11 | import { fromString } from './providers/credentials'
|
12 | 12 | import { getLogger } from '../shared/logger/logger'
|
| 13 | +import { showMessageWithUrl } from '../shared/utilities/messages' |
| 14 | +import { onceChanged } from '../shared/utilities/functionUtils' |
| 15 | + |
| 16 | +/** Shows an error message unless it is the same as the last one shown. */ |
| 17 | +const warnOnce = onceChanged((s: string, url: string) => { |
| 18 | + showMessageWithUrl(s, url, undefined, 'error') |
| 19 | +}) |
13 | 20 |
|
14 | 21 | export const ssoScope = 'sso:account:access'
|
15 | 22 | export const codecatalystScopes = ['codecatalyst:read_write']
|
@@ -255,7 +262,7 @@ export async function* loadLinkedProfilesIntoStore(
|
255 | 262 | store: ProfileStore,
|
256 | 263 | source: SsoConnection['id'],
|
257 | 264 | client: SsoClient,
|
258 |
| - profileLabel: string |
| 265 | + startUrl: string |
259 | 266 | ) {
|
260 | 267 | const accounts = new Set<string>()
|
261 | 268 | const found = new Set<Connection['id']>()
|
@@ -290,17 +297,21 @@ export async function* loadLinkedProfilesIntoStore(
|
290 | 297 | yield [id, profile] as const
|
291 | 298 | }
|
292 | 299 |
|
293 |
| - if (accounts.size === 0) { |
| 300 | + const isBuilderId = startUrl === builderIdStartUrl // Special case. |
| 301 | + if (!isBuilderId && (accounts.size === 0 || found.size === 0)) { |
| 302 | + const name = truncateStartUrl(startUrl) |
294 | 303 | // Possible causes:
|
295 | 304 | // - SSO org has no "Permission sets"
|
296 | 305 | // - user is not an "Assigned user" in any account in the SSO org
|
297 | 306 | // - user is an "Assigned user" but no "Permission sets"
|
298 |
| - getLogger().warn('auth: SSO org (%s) returned no accounts', profileLabel) |
299 |
| - } else if (found.size === 0) { |
300 |
| - getLogger().warn( |
301 |
| - 'auth: SSO org (%s) returned no IAM credentials for account: %s', |
302 |
| - profileLabel, |
303 |
| - Array.from(accounts).join() |
| 307 | + if (accounts.size === 0) { |
| 308 | + getLogger().warn('auth: SSO org (%s) returned no accounts', name) |
| 309 | + } else if (found.size === 0) { |
| 310 | + getLogger().warn('auth: SSO org (%s) returned no roles for account: %s', name, Array.from(accounts).join()) |
| 311 | + } |
| 312 | + warnOnce( |
| 313 | + `IAM Identity Center (${name}) returned no roles. Ensure the user is assigned to an account with a Permission Set.`, |
| 314 | + 'https://docs.aws.amazon.com/singlesignon/latest/userguide/getting-started.html' |
304 | 315 | )
|
305 | 316 | }
|
306 | 317 |
|
|
0 commit comments