Skip to content

Commit 96868f8

Browse files
committed
fix(credentials): send unsupported Google services straight to the JSON key advice
1 parent 2c60aa2 commit 96868f8

2 files changed

Lines changed: 17 additions & 14 deletions

File tree

‎apps/sim/lib/credentials/google-workload-identity.server.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ describe('getting a keyless Google Cloud token for a run', () => {
418418
it.each([
419419
['google-drive', 'google_keyless_delegation'],
420420
['google-bigquery', 'google_keyless_delegation_unavailable'],
421-
['google-ads', 'google_keyless_delegation_unavailable'],
421+
['google-ads', 'google_keyless_service_unsupported'],
422422
])(
423423
'refuses impersonation for %s before contacting Google, offering delegation only where it exists',
424424
async (service, step) => {

‎apps/sim/lib/credentials/google-workload-identity.server.ts‎

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -943,20 +943,23 @@ export async function resolveGoogleWorkloadIdentityToken(
943943
)
944944
}
945945
} else {
946-
if (input.impersonateEmail) {
947-
throw delegable
948-
? unsupportedUse(
949-
'google_keyless_delegation',
950-
'this keyless Google credential has no domain-wide delegation for this service',
951-
'This keyless Google credential has no domain-wide delegation for this service, so it cannot act as a Workspace user. Clear the Impersonated Account, reconnect the credential to delegate this service, or use a JSON key credential instead'
952-
)
953-
: unsupportedUse(
954-
'google_keyless_delegation_unavailable',
955-
'keyless Google credentials cannot act as a Workspace user for this service',
956-
'A keyless Google credential cannot act as a Workspace user for this service. Clear the Impersonated Account, or use a JSON key credential instead'
957-
)
946+
const cloudService = Boolean(input.service && GOOGLE_KEYLESS_SERVICES.has(input.service))
947+
// Clearing the Impersonated Account helps only where keyless works without it.
948+
if (input.impersonateEmail && delegable) {
949+
throw unsupportedUse(
950+
'google_keyless_delegation',
951+
'this keyless Google credential has no domain-wide delegation for this service',
952+
'This keyless Google credential has no domain-wide delegation for this service, so it cannot act as a Workspace user. Clear the Impersonated Account, reconnect the credential to delegate this service, or use a JSON key credential instead'
953+
)
954+
}
955+
if (input.impersonateEmail && cloudService) {
956+
throw unsupportedUse(
957+
'google_keyless_delegation_unavailable',
958+
'keyless Google credentials cannot act as a Workspace user for this service',
959+
'A keyless Google credential cannot act as a Workspace user for this service. Clear the Impersonated Account, or use a JSON key credential instead'
960+
)
958961
}
959-
if (!input.service || !GOOGLE_KEYLESS_SERVICES.has(input.service)) {
962+
if (!cloudService) {
960963
throw delegable
961964
? unsupportedUse(
962965
'google_keyless_service',

0 commit comments

Comments
 (0)