-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make authentication simpler #3
Comments
It is much simpler when running in GCP (AE or CE) when we "auto-detect" the dataset and use the instance credentials. Though we should provide "helpers" for typical boilerplate code, I am a little hesitant to add code that will work in some environment but not in other (e.g. The use of files (and providing a full path) is not going to work on App Engine). An alternative that may work for all would be to load the key bytes as a resource. Also, the suggestion above is only going to work when the password for that keystore is fixed (e.g. "notasecret") so I think the helper should provide a way to supply a different password. As for Also, env/property settings need to be documented (probably in the matching builder's setter or getter..). |
Commit a6cae12 is using now the new authkit library and when default are used (no explicit auth config settings) we will follow the gcloud authentication standard which includes using a file referenced by GOOGLE_APPLICATION_CREDENTIALS environment variable. @jgeewax do you still think we need a helper for reading PK12 files in this case? |
ping. |
Now that we're using a JSON keyfile (right?), I think the simplest and happiest way to get a Datastore instance would be... final Datastore datastore = DatastoreHelper.getOptionsfromEnv()
.dataset(datasetId)
.keyFile("/path/to/keyfile.json") // Optional if you are in GCE or GAE
.buildDatastore(); Or something similar. Is that crazy? |
Not necessarily. Do we mandate/accept only json file in the other Veneer libraries (rather than also accepting a p12 key file as well)? I was trying to see if I can extract the service email from the key (some information is there) but wasn't able to do it using the Java APis. Using a path for a file is nice but java File is not accessible on all platform and also does not cover all options (e.g. it could be provided as a bundled resource). This is why I leave it for the user to construct the Key (as described above - we could actually have that as snippet as an example in the specific Auth config class javadoc). Another option instead of File would be to accept a stream which is likely to support all various input type.
I think we should keep discussion the other suggestion of creating the service directly from the options in #54. |
Other libraries accept all of the options. Is it crazy to look up the file and check the extension, and then operate differently based on that? If so, then we could offer ...
I was under the impression that you can't get the service account e-mail from a p12 key, which was the point of the JSON keyfile (it includes all the information needed).
That makes sense. So can we simplify the "get a key" process? Maybe a final KeyStore keystore = KeyStore.getInstance("PKCS12");
final FileInputStream fis = new FileInputStream("/path/to/key.p12");
keystore.load(fis, "password".toCharArray());
final PrivateKey key = (PrivateKey) keystore.getKey("privatekey", "password".toCharArray());
final AuthConfig ac = AuthConfig.createFor("[email protected]", key);
I really like that idea! See my note above about the different forms of auth. The most common will be JSON, the next would be p12 -- nothing stopping us from having multiple "set the key for this builder" methods where the user tells us what kind of key is in the stream.
I believe so. Currently (AFAIK) there's no way to create a key with a custom password. |
@mziccard Can you summarize for me what the auth experience is like in gcloud-java world? For example, if I want to be explicit about my keyfile and project ID, and get an entity from Datastore in gcloud-node, I do: var config = {
projectId: 'grape-spaceship-123',
keyFilename: '/path/to/keyfile.json'
};
var gcloud = require('gcloud')(config);
var dataset = gcloud.datastore.dataset();
var entity = dataset.get(dataset.key(['Product', 123])); (see http://googlecloudplatform.github.io/gcloud-node/#/authentication) If I wanted to do similarly with Java (let's say I just wanted to get an entity from Datastore), what would that code look like (the explicit version)? |
@jgeewax Now you can do something like: DatastoreOptions options = DatastoreOptions.builder()
.projectId("grape-spaceship-123")
.authCredentials(AuthCredentials.createForJson(
new FileInputStream("/path/to/keyfile.json")))
.build();
Datastore datastore = DatastoreFactory.instance().get(options);
KeyFactory keyFactory = datastore.newKeyFactory().kind(KIND);
Key key = keyFactory.newKey(keyName);
Entity entity = datastore.get(key); |
This looks great ! Thanks guys ! |
Split RetryParams
- b2056bd147466fec8a817885fc5da0f5f39b5730 Integration tests for VPC-SC. (googleapis#48) by Qian Long <[email protected]> - 8ce495510ff37cb27a1c840d212288cb5c87d327 Import of package:google-cloud-spanner to GitHub Private ... by Cloud Spanner Team <[email protected]> - 8493b86 Re-generate library using google-cloud-clients/google-clo... by DPE bot <[email protected]> - 5555939 Release v0.66.1-SNAPSHOT (googleapis#3784) by Jeff Ching <[email protected]> - ed6a3f5 Release google-cloud-java v0.66.0 (googleapis#3782) by Jeff Ching <[email protected]> - 1e539fa Cloud Spanner DML & PDML Release (googleapis#3781) by snehashah16 <[email protected]> - d197058 add null check to JobInfo.fromPb(Job) and .toPb() (googleapis#3770) by sombra-mykola-bakay <[email protected]> - 211bfad Add synthtool scripts (googleapis#3765) by Jeff Ching <[email protected]> - 4813432 Add listDocuments() API (googleapis#3759) by Sebastian Schmidt <[email protected]> - 0f3bc0e Don't raise empty Snapshots on resets (googleapis#3750) by Sebastian Schmidt <[email protected]> - 63aff86 Remove CircleCI status, coveralls, and version eye badges... by Jeff Ching <[email protected]> - 6a8e5d6 Bump to next snapshot version (googleapis#3768) by Jeff Ching <[email protected]> - 1093938 Release 1.47.0/0.65.0 (googleapis#3767) by Jeff Ching <[email protected]> - f69710d Deprecate getCollections in favor of listCollections (googleapis#37... by Sebastian Schmidt <[email protected]> - 7f74c5a [Storage] Add launch stage annotations around bucket lock... by Frank Natividad <[email protected]> - 152653d Regenerate clients (googleapis#3766) by Jeff Ching <[email protected]> - 68f38e1 Revert "Revert "Revert "Cloud Spanner DML & PartitionedDM... by Jeff Ching <[email protected]> - f741fc0 Fix README typo (googleapis#3762) by ihommani <[email protected]> - 65ca2f3 Revert "Revert "Cloud Spanner DML & PartitionedDML suppor... by Jeff Ching <[email protected]> - 6ebbc19 fix incorrect link (googleapis#3748) by Elliotte Rusty Harold <[email protected]> - bcb28f2 [Storage] Bucket Lock (googleapis#3727) by Frank Natividad <[email protected]> - c79f280 spanner: Expand test coverage for GrpcResultSet and runWi... by Nithin Sujir <[email protected]> - fdccb0b Bump to next snapshot version (googleapis#3744) by JesseLovelace <[email protected]> - 456e8fb Release 1.46.0/0.64.0 (googleapis#3742) by JesseLovelace <[email protected]> - 82fda75 spanner: Expand test coverage for SpannerClient (googleapis#3725) by Nithin Sujir <[email protected]> - 9187488 Fix parent/child spans relationship in Spanner. (googleapis#3690) by Bogdan Drutu <[email protected]> - 3c9bbf2 Revert "Cloud Spanner DML & PartitionedDML support (googleapis#3703... by JesseLovelace <[email protected]> - c163907 Cloud Spanner DML & PartitionedDML support (googleapis#3703) by snehashah16 <[email protected]> - 626e4d1 Regenerate clients (googleapis#3738) by JesseLovelace <[email protected]> - ba388da Remove duplicated folders (googleapis#3732) by Jeff Ching <[email protected]> - d739242 spanner: Options: Fix null dereference, expand test cover... by Nithin Sujir <[email protected]> - 7499c31 Remove Circle CI and Travis configs (googleapis#3723) by Jeff Ching <[email protected]> - 7a72784 Remove dependency on vulnerable version of jackson, upgra... by JesseLovelace <[email protected]> - 2c284dd Add retries to downloadEmulator() to mitigate transient n... by JesseLovelace <[email protected]> - 6955469 bump proto version (googleapis#3718) by Hanzhen Yi <[email protected]> - 9ab7770 Add ArrayUnion/ArrayRemove conformance tests (googleapis#3704) by Sebastian Schmidt <[email protected]> - 36409f5 Bump version to 0.63.1-beta-SNAPSHOT (googleapis#3714) by JesseLovelace <[email protected]> - 94f19b7 Regenerate clients (googleapis#3713) by JesseLovelace <[email protected]> - 7a43f6f Release 1.45.0/0.63.0 (googleapis#3710) by JesseLovelace <[email protected]> - b533c9c Add region tags around an informative sample. (googleapis#3705) by Frank Natividad <[email protected]> - e8cff3f Spanner: Block nested transactions (googleapis#3628) by Nithin Sujir <[email protected]> - 7869364 Migrate Pub/Sub client to ApiFutures. (googleapis#3700) by Anuraag Agrawal <[email protected]> - e310f6d ci: make javadoc not spam us (googleapis#3699) by Michael Darakananda <[email protected]> - fbf8715 Clean up snippets for BatchClient and Spanner (googleapis#3684) by Nithin Sujir <[email protected]> - 3fa1fa0 Bigtable: limit mutation sizes in the client to avoid ove... by Igor Bernstein <[email protected]> - f977c8a bigquery: properly fail when setting TableId's project tw... by Marcello Steiner <[email protected]> - c90b5ba Bigtable: add await replication (googleapis#3658) by Igor Bernstein <[email protected]> - 43d53a8 Bigtable: wrap proto enums (googleapis#3659) by Igor Bernstein <[email protected]> - 6f1a105 Bigtable: add enhanced stub for bigtable table admin clie... by Igor Bernstein <[email protected]> - 68e1717 Kokoro additions (googleapis#3685) by Jeff Ching <[email protected]> - a175980 spanner: expand test coverage for getDatabaseClient() (googleapis#3... by Nithin Sujir <[email protected]> - ae614b3 pubsub: add Publisher.awaitTermination (googleapis#3688) by Michael Darakananda <[email protected]> - 739d519 Add downloadFile sample and reformat storage snippets (googleapis#3... by Frank Natividad <[email protected]> - c901932 storage: include information on a bucket prefix (googleapis#3671) by Frank Natividad <[email protected]> - 713cb88 link to google-cloud-logging from README (googleapis#3681) by Elliotte Rusty Harold <[email protected]> - 5ccfc3a spanner: Add snippets for ReadContext (googleapis#3662) by Nithin Sujir <[email protected]> - ccf68f3 Verify protoc version for batch-generation (googleapis#3676) by Andrea Lin <[email protected]> - 1d7b95f Add Kokoro CI config (googleapis#3664) by Jeff Ching <[email protected]> - e855d48 Bump to next snapshot versions (googleapis#3679) by Garrett Jones <[email protected]> - bbede73 Release 1.44.0/0.62.0 (googleapis#3677) by Garrett Jones <[email protected]> - a420738 Weekly proto refresh (googleapis#3674) by Garrett Jones <[email protected]> - 705acb7 update gax to 1.31/0.48 (googleapis#3675) by Hanzhen Yi <[email protected]> - eadf7bc Adding redis-v1 and video-intelligence-v1p2beta1 (googleapis#3669) by Garrett Jones <[email protected]> - f098439 Regenerate proto/grpc files with protoc 3.6.0 (googleapis#3672) by Andrea Lin <[email protected]> - 4d1da48 Add redis-v1 and video-intelligence-v1p2beta1 to batch (#... by Garrett Jones <[email protected]> - 80c9675 Fixes for ITComputeTest (googleapis#3667) by Andrea Lin <[email protected]> - 509b079 Releasing.md instructions to uncomment nexus-staging-mave... by Andrea Lin <[email protected]> - a2f7111 Add handwritten integration test for Compute GAPIC (googleapis#3660) by Andrea Lin <[email protected]> - 0e58b7d bigtable: RowMutation should allow passing of a Mutation ... by ajaaym <[email protected]> - 37675e9 Bump to snapshot version for development (googleapis#3656) by Andrea Lin <[email protected]> - e4b5266 Release 0.61.0/1.43.0 (googleapis#3653) by Andrea Lin <[email protected]> - 20c329a Javadoc fixes for Bigtable client (googleapis#3652) by Andrea Lin <[email protected]> - d235a82 tell JVM to use less memory when testing (googleapis#3650) by Michael Darakananda <[email protected]> - a9860b3 Bigtable: improve list tables spooler (googleapis#3639) by Igor Bernstein <[email protected]> - 01bec2b Refresh all clients (googleapis#3647) by Andrea Lin <[email protected]> - 0bef731 Bigtable: cosmetic cleanup of table admin (googleapis#3638) by Igor Bernstein <[email protected]> - 3cefb4f Bigtable: table model improvements (googleapis#3640) by Igor Bernstein <[email protected]> - 47bd674 Fix logging integration test failure on when running on G... by Hanzhen Yi <[email protected]> - 124ed55 Revert "[Storage] Bucket lock (googleapis#3574)" (googleapis#3644) by Frank Natividad <[email protected]> - 7f3ab97 Regenerate compute (googleapis#3642) by Andrea Lin <[email protected]> - 9f1a96b [Storage] Bucket lock (googleapis#3574) by Frank Natividad <[email protected]> - 5e3b897 pubsub: clean up after extension gives up (googleapis#3633) by Chris Sainty <[email protected]> - f4bc56d make DatastoreBatchWriter public (googleapis#3387) by Daniel Norberg <[email protected]> - c81ff3e Bigtable: add resource level IAM (googleapis#3624) by Igor Bernstein <[email protected]> - c715fc6 Update signUrl documentation (googleapis#3546) by Jeff Ching <[email protected]> - d7a135a google-cloud-nio: retry on 502 errors, and increase max d... by droazen <[email protected]> - 1f12a83 spanner: Add snippets for Spanner, BatchClient and BatchR... by Nithin Sujir <[email protected]> - 997d2a3 Bigtable: add CRUD for AppProfiles (googleapis#3619) by Igor Bernstein <[email protected]> - e3eedeb Bigtable: add CRUD for clusters (googleapis#3612) by Igor Bernstein <[email protected]> - 8bcc89b Bigtable: clean up consistency token (googleapis#3570) by Igor Bernstein <[email protected]> - 427b155 Bigtable: add CRUD for instances (googleapis#3569) by Igor Bernstein <[email protected]> - b9b4aff fix logging unit tests (googleapis#3630) by Hanzhen Yi <[email protected]> - ff2ed5e bump to snapshot version (googleapis#3625) by Hanzhen Yi <[email protected]> - 4cd518d Release 0.60.0 (googleapis#3623) by Hanzhen Yi <[email protected]> - 3d1e971 batch generation before release (googleapis#3622) by Hanzhen Yi <[email protected]> - 08a5e46 [Storage] Make StorageIT easier to setup with new project... by Frank Natividad <[email protected]> - 4eca7a4 upgrade auth version (googleapis#3606) by Elliotte Rusty Harold <[email protected]> - 8f44a9a removing word "natural" from product name (googleapis#3610) by Vincent <[email protected]> - 4c3e3d1 Fix documentation for setParallelPullCount (googleapis#3542) by Jonas Wiklund <[email protected]> - 5fc0dbd bump version for development (googleapis#3599) by Michael Darakananda <[email protected]> (And 1760 more changes) GitOrigin-RevId: b2056bd147466fec8a817885fc5da0f5f39b5730
🤖 I have created a release \*beep\* \*boop\* --- ## 0.1.0 (2020-10-01) ### Features * initial client generation ([07f53d9](https://www.github.com/googleapis/java-workflows/commit/07f53d95b527d76aa80c49c6ff7e8fc3b07d40e8)) ### Dependencies * update dependency com.google.cloud:google-cloud-shared-dependencies to v0.10.0 ([#15](https://www.github.com/googleapis/java-workflows/issues/15)) ([f99ec48](https://www.github.com/googleapis/java-workflows/commit/f99ec4893910cd865876cd0526881b18562cee50)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please).
…gins-maven-deploy-plugin-3.x build(deps): update dependency org.apache.maven.plugins:maven-deploy-plugin to v3
…-info-reports-plugin to v3.4.1 (#3) * build(deps): update dependency org.apache.maven.plugins:maven-project-info-reports-plugin to v3.4.1 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
…plugin to v3 (#3) [](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [org.apache.maven.plugins:maven-deploy-plugin](https://maven.apache.org/plugins/) | `2.8.2` -> `3.0.0` | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Renovate will not automatically rebase this PR, because other commits have been found. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, click this checkbox. ⚠ **Warning**: custom changes will be lost. --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/googleapis/java-beyondcorp-clientgateways). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzMi4xNjMuMCIsInVwZGF0ZWRJblZlciI6IjMyLjE2My4wIn0=-->
…plugin to v3 (#3) [](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [org.apache.maven.plugins:maven-deploy-plugin](https://maven.apache.org/plugins/) | `2.8.2` -> `3.0.0` | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Renovate will not automatically rebase this PR, because other commits have been found. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, click this checkbox. ⚠ **Warning**: custom changes will be lost. --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/googleapis/java-cloudcommerceconsumerprocurement). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzMi4xNjMuMCIsInVwZGF0ZWRJblZlciI6IjMyLjE2My4wIn0=-->
…plugin to v3 (#3) [](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [org.apache.maven.plugins:maven-deploy-plugin](https://maven.apache.org/plugins/) | `2.8.2` -> `3.0.0` | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Renovate will not automatically rebase this PR, because other commits have been found. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, click this checkbox. ⚠ **Warning**: custom changes will be lost. --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/googleapis/java-beyondcorp-appconnections). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzMi4xNzYuMCIsInVwZGF0ZWRJblZlciI6IjMyLjE3Ni4wIn0=-->
…plugin to v3 (#3) [](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [org.apache.maven.plugins:maven-deploy-plugin](https://maven.apache.org/plugins/) | `2.8.2` -> `3.0.0` | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Renovate will not automatically rebase this PR, because other commits have been found. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, click this checkbox. ⚠ **Warning**: custom changes will be lost. --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/googleapis/java-beyondcorp-appgateways). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzMi4xNzYuMCIsInVwZGF0ZWRJblZlciI6IjMyLjE3Ni4wIn0=-->
What we do today:
What we'd like to do:
The text was updated successfully, but these errors were encountered: