Skip to content

Use local private credentials (json key file) to refresh GCS access token#14585

Merged
zhenxiao merged 6 commits intoprestodb:masterfrom
beinan:gcs_private_key_auth
Aug 2, 2020
Merged

Use local private credentials (json key file) to refresh GCS access token#14585
zhenxiao merged 6 commits intoprestodb:masterfrom
beinan:gcs_private_key_auth

Conversation

@beinan
Copy link
Member

@beinan beinan commented May 28, 2020

Generating and refresh GCS access token by the local private credentials (json key file)
Support the credentials of either "service_account" or "authorized_user" type
Added to both presto-cli and presto-jdbc

== RELEASE NOTES ==

General Changes
* Use local private credentials (json key file) to refresh GCS access token
presto-cli --extra-credential hive.gcs.credentials.path="${PRIVATE_KEY_JSON_PATH}"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to hardcode the URL here? Maybe we can move it to a static variable.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, will extract it as a constant val

Copy link
Member

@ChunxuTang ChunxuTang May 28, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The GCP documentation here (https://developers.google.com/identity/protocols/oauth2) recommends creating a signed JWT with the client ID and a private key from the GCP credential. Is this step automatically covered in the Google OAuth libs?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call, I guess not. I will post another commit or PR to support JWT with a given client ID

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the synchronized keyword necessary here? Will this function be invoked in a multi-threaded situation?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call. This interceptor is used by presto-cli and presto-jdbc. I think presto-jdbc might have some queries running in parallel. Even for a single query, during the http conversation, there are still multiple http calls, some of which might be triggered in an asynchronous way.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha. Thanks for your explanation.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add one blank line between private static final and private final

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shall we keep hive here? kind of misleading. If the session property is already defined, could we import the string from other class?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "hive.gcs.credentials.path" is the key I newly added. The other 'hive.gcs.oauth' is an existing one, which can be also found in presto-hive.

presto-hive/src/main/java/com/facebook/presto/hive/gcs/GcsConfigurationProvider.java
28: private static final String GCS_OAUTH_KEY = "hive.gcs.oauth";

If we imported the constant "hive.gcs.oauth" from presto-hive, we might introduce a new dependency from presto-client to presto-hive. Shall we do that?

I'm just thinking the name of these two keys need to be consistent.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get it. no need to have dependency from presto-hive
keep hive.gcs.credentials.path is fine

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this blank line

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

pom.xml Outdated
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, this PR is a dependency of:
prestodb/presto-hadoop-apache#43

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have updated the version to 2.7.4-8 in another pr

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

static import GCSOAuthInterceptor.GCS_CREDENTIALS_PATH_KEY

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@beinan beinan force-pushed the gcs_private_key_auth branch from 4e3b2d6 to 11bc554 Compare July 17, 2020 08:53
@beinan beinan force-pushed the gcs_private_key_auth branch 2 times, most recently from 47236c3 to 56c88e1 Compare July 31, 2020 08:04
@beinan beinan force-pushed the gcs_private_key_auth branch from 56c88e1 to e852a2b Compare July 31, 2020 18:46
</exclusion>
</exclusions>
</dependency>

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shall we keep the blank line?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

</exclusion>
</exclusions>
</dependency>

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

keep the blank line for format

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Collaborator

@zhenxiao zhenxiao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
@beinan could you please re-run the test?

@beinan beinan force-pushed the gcs_private_key_auth branch 3 times, most recently from b17a3e0 to 09af78c Compare August 1, 2020 07:02
@beinan beinan force-pushed the gcs_private_key_auth branch from 09af78c to 5bb0689 Compare August 2, 2020 05:29
@zhenxiao zhenxiao merged commit 24ac335 into prestodb:master Aug 2, 2020
mayankgarg1990 pushed a commit to mayankgarg1990/presto that referenced this pull request Aug 3, 2020
prestodb#14585 introduced new dependencies that entered
presto-jdbc uber jar. presto-jdbc shades out all dependencies other than the core jdbc
classes itself and this PR does the same.
wenleix pushed a commit that referenced this pull request Aug 3, 2020
#14585 introduced new dependencies that entered
presto-jdbc uber jar. presto-jdbc shades out all dependencies other than the core jdbc
classes itself and this PR does the same.
@caithagoras caithagoras mentioned this pull request Aug 14, 2020
7 tasks
shangxinli pushed a commit to shangxinli/presto that referenced this pull request Nov 18, 2020
prestodb#14585 introduced new dependencies that entered
presto-jdbc uber jar. presto-jdbc shades out all dependencies other than the core jdbc
classes itself and this PR does the same.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants