-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Storage: HMAC service account support #5284
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
Changes from 2 commits
11ffccc
fe560aa
2375c85
42569aa
a09334c
89d165b
7be7c2b
4bb6b44
91287cd
82259e4
46f4e29
df99b6d
ab32675
9e185bb
6d6fd4b
46fc073
cefd5ea
6dc9627
6998a83
0a8abee
16a3c60
af8bfd6
584015f
8760589
55f1ef4
5cfdea5
61187df
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,3 +25,8 @@ env_vars: { | |
| key: "GOOGLE_APPLICATION_CREDENTIALS" | ||
| value: "keystore/73713_java_it_service_account" | ||
| } | ||
|
|
||
| env_vars: { | ||
| key: "IT_SERVICE_ACCOUNT_EMAIL" | ||
| value: "[email protected]" | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2709,17 +2709,117 @@ Blob create( | |
| */ | ||
| List<Acl> listAcls(BlobId blob); | ||
|
|
||
| /** | ||
| * Creates a new HMAC Key for the provided service account, including the secret key. Note that | ||
| * the secret key is only returned upon creation via this method. | ||
| * | ||
| * <p>Example of creating a new HMAC Key. | ||
| * | ||
| * <pre>{@code | ||
| * ServiceAccount serviceAccount = ServiceAccount.of("[email protected]"); | ||
| * | ||
| * HmacKey hmacKey = storage.createHmacKey(serviceAccount); | ||
| * | ||
| * String secretKey = hmacKey.getSecretKey(); | ||
| * HmacKey.HmacKeyMetadata metadata = hmacKey.getMetadata(); | ||
| * }</pre> | ||
| * | ||
| * @throws StorageException upon failure | ||
| */ | ||
| HmacKey createHmacKey(ServiceAccount serviceAccount); | ||
|
||
|
|
||
| /** | ||
| * Lists HMAC keys for a given service account. Note this returns {@code HmacKeyMetadata} objects, | ||
| * which do not contain secret keys. | ||
| * | ||
| * <p>Example of listing HMAC keys, specifying max results. | ||
| * | ||
| * <pre>{@code | ||
| * ServiceAccount serviceAccount = ServiceAccount.of("[email protected]"); | ||
|
||
| * | ||
| * Page<HmacKey.HmacKeyMetadata> metadataPage = storage.listHmacKeys(serviceAccount, null, 10); | ||
|
||
| * for (HmacKey.HmacKeyMetadata hmacKeyMetadata : metadataPage.getValues()) { | ||
| * //do something with the metadata | ||
| * } | ||
| * }</pre> | ||
| * | ||
| * @param serviceAccount the service account whose HMAC keys to list | ||
| * @param pageToken the page from which to start results | ||
| * @param maxResults the maximum amount of results that can be returned by this request | ||
| * @param showDeletedKeys whether to show keys with the DELETED state in the result | ||
| * @throws StorageException upon failure | ||
| */ | ||
| Page<HmacKeyMetadata> listHmacKeys( | ||
| ServiceAccount serviceAccount, String pageToken, Long maxResults); | ||
| ServiceAccount serviceAccount, String pageToken, Long maxResults, boolean showDeletedKeys); | ||
|
||
|
|
||
| /** | ||
| * Lists HMAC keys for a given service account. Note this returns {@code HmacKeyMetadata} objects, | ||
|
||
| * which do not contain secret keys. This is the same as calling {@code | ||
| * listHmacKeys(serviceAccount, null, null, false)}. | ||
| * | ||
| * <p>Example of listing HMAC keys. | ||
| * | ||
| * <pre>{@code | ||
| * ServiceAccount serviceAccount = ServiceAccount.of("[email protected]"); | ||
| * | ||
| * Page<HmacKey.HmacKeyMetadata> metadataPage = storage.listHmacKeys(serviceAccount); | ||
| * for (HmacKey.HmacKeyMetadata hmacKeyMetadata : metadataPage.getValues()) { | ||
| * //do something with the metadata | ||
| * } | ||
frankyn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| * }</pre> | ||
| * | ||
| * @throws StorageException upon failure | ||
| */ | ||
| Page<HmacKeyMetadata> listHmacKeys(ServiceAccount serviceAccount); | ||
|
||
|
|
||
| /** | ||
| * Gets an HMAC key given its access id. Note that this returns a {@code HmacKeyMetadata} object, | ||
| * which does not contain the secret key. | ||
| * | ||
| * <p>Example of getting an HMAC key. | ||
| * | ||
| * <pre>{@code | ||
| * String hmacKeyAccessId = "my-access-id"; | ||
| * HmacKey.HmackeyMetadata hmacKeyMetadata = storage.getHmacKey(hmacKeyAccessId); | ||
frankyn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| * }</pre> | ||
| * | ||
| * @throws StorageException upon failure | ||
| */ | ||
| HmacKeyMetadata getHmacKey(String accessId); | ||
|
||
|
|
||
| /** | ||
| * Deletes an HMAC key given its access ID. Note that only an {@code INACTIVE} key can be deleted. | ||
| * Attempting to delete a key whose {@code HmacKey.HmacKeyState} is anything other than {@code | ||
| * INACTIVE} will fail. | ||
| * | ||
| * <p>Example of updating an HMAC key's state to INACTIVE and then deleting it. | ||
| * | ||
| * <pre>{@code | ||
| * String hmacKeyAccessId = "my-access-id"; | ||
| * HmacKey.HmacKeyMetadata hmacKeyMetadata = storage.getHmacKey(hmacKeyAccessId); | ||
| * | ||
| * storage.updateHmacKeyState(hmacKeyMetadata, HmacKey.HmacKeyState.INACTIVE); | ||
| * storage.deleteHmacKey(hmacKeyMetadata.getAccessId()); | ||
| * }</pre> | ||
| * | ||
| * @throws StorageException upon failure | ||
| */ | ||
| void deleteHmacKey(String accessId); | ||
|
||
|
|
||
| /** | ||
| * Updates the state of an HMAC key and returns the updated metadata. | ||
| * | ||
| * <p>Example of updating the state of a newly created HMAC key. | ||
| * | ||
| * <pre>{@code | ||
| * ServiceAccount serviceAccount = ServiceAccount.of("[email protected]"); | ||
| * HmacKey key = storage.createHmacKey(serviceAccount); | ||
|
||
| * | ||
| * storage.updateHmacKeyState(hmacKey.getMetadata(), HmacKey.HmacKeyState.INACTIVE); | ||
| * }</pre> | ||
| * | ||
| * @throws StorageException upon failure | ||
| */ | ||
| HmacKeyMetadata updateHmacKeyState( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice helper method! (no action required). |
||
| final HmacKeyMetadata hmacKeyMetadata, final HmacKey.HmacKeyState state); | ||
|
||
| /** | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not super familiar with documenting Java code, but can we add a note saying the
secretis only available on creation?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah--I'm planning to add the documentation once the code is otherwise approved