MCPcopy Create free account
hub / github.com/freecodexyz/free-code / runAwsAuthRefresh

Function runAwsAuthRefresh

src/utils/auth.ts:613–645  ·  view source on GitHub ↗

* Run awsAuthRefresh to perform interactive authentication (e.g., aws sso login) * Streams output in real-time for user visibility

()

Source from the content-addressed store, hash-verified

611 * Streams output in real-time for user visibility
612 */
613async function runAwsAuthRefresh(): Promise<boolean> {
614 const awsAuthRefresh = getConfiguredAwsAuthRefresh()
615
616 if (!awsAuthRefresh) {
617 return false // Not configured, treat as success
618 }
619
620 // SECURITY: Check if awsAuthRefresh is from project settings
621 if (isAwsAuthRefreshFromProjectSettings()) {
622 // Check if trust has been established for this project
623 const hasTrust = checkHasTrustDialogAccepted()
624 if (!hasTrust && !getIsNonInteractiveSession()) {
625 const error = new Error(
626 `Security: awsAuthRefresh executed before workspace trust is confirmed. If you see this message, post in ${MACRO.FEEDBACK_CHANNEL}.`,
627 )
628 logAntError('awsAuthRefresh invoked before trust check', error)
629 logEvent('tengu_awsAuthRefresh_missing_trust', {})
630 return false
631 }
632 }
633
634 try {
635 logForDebugging('Fetching AWS caller identity for AWS auth refresh command')
636 await checkStsCallerIdentity()
637 logForDebugging(
638 'Fetched AWS caller identity, skipping AWS auth refresh command',
639 )
640 return false
641 } catch {
642 // only actually do the refresh if caller-identity calls
643 return refreshAwsAuth(awsAuthRefresh)
644 }
645}
646
647// Timeout for AWS auth refresh command (3 minutes).
648// Long enough for browser-based SSO flows, short enough to prevent indefinite hangs.

Callers 1

auth.tsFile · 0.85

Calls 9

logAntErrorFunction · 0.85
logEventFunction · 0.85
logForDebuggingFunction · 0.85
checkStsCallerIdentityFunction · 0.85
refreshAwsAuthFunction · 0.85

Tested by

no test coverage detected