Skip to content

Commit fd8f6c5

Browse files
committed
support impersonation for all types
1 parent 191b05b commit fd8f6c5

1 file changed

Lines changed: 16 additions & 22 deletions

File tree

java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryJdbcOAuthUtility.java

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -230,27 +230,22 @@ static Map<String, String> parseOAuthProperties(DataSource ds, String callerClas
230230
break;
231231
}
232232

233-
if (authType == AuthType.GOOGLE_SERVICE_ACCOUNT
234-
|| authType == AuthType.GOOGLE_USER_ACCOUNT
235-
|| authType == AuthType.PRE_GENERATED_TOKEN
236-
|| authType == AuthType.APPLICATION_DEFAULT_CREDENTIALS) {
237-
oauthProperties.put(
238-
BigQueryJdbcUrlUtility.OAUTH_SA_IMPERSONATION_EMAIL_PROPERTY_NAME,
239-
ds.getOAuthSAImpersonationEmail());
240-
oauthProperties.put(
241-
BigQueryJdbcUrlUtility.OAUTH_SA_IMPERSONATION_CHAIN_PROPERTY_NAME,
242-
ds.getOAuthSAImpersonationChain());
243-
oauthProperties.put(
244-
BigQueryJdbcUrlUtility.OAUTH_SA_IMPERSONATION_SCOPES_PROPERTY_NAME,
245-
ds.getOAuthSAImpersonationScopes() != null
246-
? ds.getOAuthSAImpersonationScopes()
247-
: BIGQUERY_SCOPE);
248-
oauthProperties.put(
249-
BigQueryJdbcUrlUtility.OAUTH_SA_IMPERSONATION_TOKEN_LIFETIME_PROPERTY_NAME,
250-
ds.getOAuthSAImpersonationTokenLifetime() != null
251-
? ds.getOAuthSAImpersonationTokenLifetime()
252-
: BigQueryJdbcUrlUtility.DEFAULT_OAUTH_SA_IMPERSONATION_TOKEN_LIFETIME_VALUE);
253-
}
233+
oauthProperties.put(
234+
BigQueryJdbcUrlUtility.OAUTH_SA_IMPERSONATION_EMAIL_PROPERTY_NAME,
235+
ds.getOAuthSAImpersonationEmail());
236+
oauthProperties.put(
237+
BigQueryJdbcUrlUtility.OAUTH_SA_IMPERSONATION_CHAIN_PROPERTY_NAME,
238+
ds.getOAuthSAImpersonationChain());
239+
oauthProperties.put(
240+
BigQueryJdbcUrlUtility.OAUTH_SA_IMPERSONATION_SCOPES_PROPERTY_NAME,
241+
ds.getOAuthSAImpersonationScopes() != null
242+
? ds.getOAuthSAImpersonationScopes()
243+
: BIGQUERY_SCOPE);
244+
oauthProperties.put(
245+
BigQueryJdbcUrlUtility.OAUTH_SA_IMPERSONATION_TOKEN_LIFETIME_PROPERTY_NAME,
246+
ds.getOAuthSAImpersonationTokenLifetime() != null
247+
? ds.getOAuthSAImpersonationTokenLifetime()
248+
: BigQueryJdbcUrlUtility.DEFAULT_OAUTH_SA_IMPERSONATION_TOKEN_LIFETIME_VALUE);
254249
return oauthProperties;
255250
}
256251

@@ -288,7 +283,6 @@ static GoogleCredentials getCredentials(
288283
credentials = getApplicationDefaultCredentials(callerClassName);
289284
break;
290285
case EXTERNAL_ACCOUNT_AUTH:
291-
// This auth method doesn't support service account impersonation
292286
credentials = getExternalAccountAuthCredentials(authProperties, callerClassName);
293287
break;
294288
default:

0 commit comments

Comments
 (0)