* Run awsAuthRefresh to perform interactive authentication (e.g., aws sso login) * Streams output in real-time for user visibility
()
| 660 | * Streams output in real-time for user visibility |
| 661 | */ |
| 662 | async function runAwsAuthRefresh(): Promise<boolean> { |
| 663 | const awsAuthRefresh = getConfiguredAwsAuthRefresh() |
| 664 | |
| 665 | if (!awsAuthRefresh) { |
| 666 | return false // Not configured, treat as success |
| 667 | } |
| 668 | |
| 669 | // SECURITY: Check if awsAuthRefresh is from project settings |
| 670 | if (isAwsAuthRefreshFromProjectSettings()) { |
| 671 | // Check if trust has been established for this project |
| 672 | const hasTrust = checkHasTrustDialogAccepted() |
| 673 | if (!hasTrust && !getIsNonInteractiveSession()) { |
| 674 | const error = new Error( |
| 675 | `Security: awsAuthRefresh executed before workspace trust is confirmed. If you see this message, post in ${MACRO.FEEDBACK_CHANNEL}.`, |
| 676 | ) |
| 677 | logAntError('awsAuthRefresh invoked before trust check', error) |
| 678 | logEvent('tengu_awsAuthRefresh_missing_trust', {}) |
| 679 | return false |
| 680 | } |
| 681 | } |
| 682 | |
| 683 | try { |
| 684 | logForDebugging('Fetching AWS caller identity for AWS auth refresh command') |
| 685 | await checkStsCallerIdentity() |
| 686 | logForDebugging( |
| 687 | 'Fetched AWS caller identity, skipping AWS auth refresh command', |
| 688 | ) |
| 689 | return false |
| 690 | } catch { |
| 691 | // only actually do the refresh if caller-identity calls |
| 692 | return refreshAwsAuth(awsAuthRefresh) |
| 693 | } |
| 694 | } |
| 695 | |
| 696 | // Timeout for AWS auth refresh command (3 minutes). |
| 697 | // Long enough for browser-based SSO flows, short enough to prevent indefinite hangs. |
no test coverage detected