Repository navigation
fix(bigquery-jdbc): allow OAuthPvtKey without OAuthServiceAcctEmail for JSON service account keys - #15061
Open
logachev wants to merge 2 commits into
Open
fix(bigquery-jdbc): allow OAuthPvtKey without OAuthServiceAcctEmail for JSON service account keys#15061logachev wants to merge 2 commits into
logachev wants to merge 2 commits into
Conversation
…or JSON service account keys When using Service Account authentication (OAuthType=0) with an inline JSON key (or JSON key file path) in OAuthPvtKey, BigQueryJdbcOAuthUtility.parseOAuthProperties gated OAuthPvtKey on serviceAccountEmail != null. If OAuthServiceAcctEmail was omitted or passed as an empty string via Properties (which appendPropertiesToURL drops), OAuthPvtKey was silently ignored and getGoogleServiceAccountCredentials threw 'No valid credentials provided.', even though JSON keys contain client_email. - Accept non-blank OAuthPvtKey in parseOAuthProperties without requiring OAuthServiceAcctEmail, falling back to OAuthPvtKeyPath when OAuthPvtKey is null or blank. - Reject missing or blank OAuthServiceAcctEmail for non-JSON keys (PKCS#8 or P12) with an explicit error message. - Use explicit UTF-8 encoding in isJson and OAuthPvtKey byte conversion. - Add unit tests covering OAuthPvtKey with omitted/empty/whitespace OAuthServiceAcctEmail across URL, Properties, and DataSource paths.
Contributor
There was a problem hiding this comment.
Code Review
This pull request updates the Google Service Account authentication logic in the BigQuery JDBC driver. Specifically, it removes the requirement for OAuthServiceAcctEmail when using JSON-based service account keys, while ensuring it remains mandatory for PKCS#8 and P12 private keys. It also introduces strict UTF-8 encoding handling for JSON parsing and private key bytes, adds robust null and empty checks, and includes comprehensive unit tests to validate these authentication scenarios. I have no feedback to provide as there are no review comments.
…key-without-email # Conflicts: # java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/BigQueryDriverTest.java
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When using Service Account authentication (OAuthType=0) with an inline JSON key (or JSON key file path) in OAuthPvtKey, BigQueryJdbcOAuthUtility.parseOAuthProperties gated OAuthPvtKey on serviceAccountEmail != null. If OAuthServiceAcctEmail was omitted or passed as an empty string via Properties (which appendPropertiesToURL drops), OAuthPvtKey was silently ignored and getGoogleServiceAccountCredentials threw 'No valid credentials provided.', even though JSON keys contain client_email.