Skip to content

Commit

Permalink
STG95 Beta Features (#41432)
Browse files Browse the repository at this point in the history
* STG95 Versions and recording changes (#41069)

* initial service version changes

* assets updates

* adding missing recording

* STG95 Files OAuth - full data plane support (#41239)

* STG94 Files OAuth - full data plane support (#39653)

* swagger

* tests

* missed recording

* link and quotaInGB description changes

* missed conflict

* adding storageerror copy blob parameters back as it doesn't effect api views

* test recordings, changing min service version for tests, and re-generating storage error

* STG95 Add support to log stringToSign for SAS (#41219)

* everything

* adding missing account sas string to sign

* adding javadoc deprecated tags

* removing deprecated tag

* fixing javadoc

* feature overhaul

* missed removal

* STG95 Files Binary ACE (#41238)

* wip

* implementation wihtout tests

* adding storageerror copy blob parameters back as it doesn't effect api views

* formatting

* fixing possible breaking change

* re-removing copy source vars from storage error and removing a test that works now

* adding filepermissionformat to models and deleting one in implementation

* spotbugs exclusions and style

* tests

* style

* addressing api review comments

* style

* mistake

* adding create directory overload, moving test supplier to testhelper

* removing redundant method

* updating recordings

* STG95 Premium Files – Paid Burst IOPS/Bandwidth (#41218)

* implementation without tests

* tests and adding missed model helper

* adding storageerror copy blob parameters back as it doesn't effect api views

* test recordings, and re-generating storageerror

* removing working test and unused import

* addressing api review comments

* adding test for paidburstingenabledfalse

* removing unused import

* updating recordings

* adding features to changelogs
  • Loading branch information
ibrandes committed Aug 6, 2024
1 parent 9dceb28 commit 046664f
Show file tree
Hide file tree
Showing 80 changed files with 4,631 additions and 710 deletions.
1 change: 1 addition & 0 deletions sdk/storage/azure-storage-blob/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## 12.28.0-beta.1 (Unreleased)

### Features Added
- Added ability to retrieve SAS string to sign for debugging purposes.

### Breaking Changes

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
import java.util.List;
import java.util.Map;
import java.util.function.BiFunction;
import java.util.function.Consumer;
import java.util.stream.Collectors;

import static com.azure.core.util.FluxUtil.monoError;
Expand Down Expand Up @@ -1624,8 +1625,29 @@ public String generateUserDelegationSas(BlobServiceSasSignatureValues blobServic
*/
public String generateUserDelegationSas(BlobServiceSasSignatureValues blobServiceSasSignatureValues,
UserDelegationKey userDelegationKey, String accountName, Context context) {
return generateUserDelegationSas(blobServiceSasSignatureValues, userDelegationKey, accountName,
null, context);
}

/**
* Generates a user delegation SAS for the container using the specified {@link BlobServiceSasSignatureValues}.
* <p>See {@link BlobServiceSasSignatureValues} for more information on how to construct a user delegation SAS.</p>
*
* @param blobServiceSasSignatureValues {@link BlobServiceSasSignatureValues}
* @param userDelegationKey A {@link UserDelegationKey} object used to sign the SAS values.
* See {@link BlobServiceAsyncClient#getUserDelegationKey(OffsetDateTime, OffsetDateTime)} for more information on
* how to get a user delegation key.
* @param accountName The account name.
* @param stringToSignHandler For debugging purposes only. Returns the string to sign that was used to generate the
* signature.
* @param context Additional context that is passed through the code when generating a SAS.
*
* @return A {@code String} representing the SAS query parameters.
*/
public String generateUserDelegationSas(BlobServiceSasSignatureValues blobServiceSasSignatureValues,
UserDelegationKey userDelegationKey, String accountName, Consumer<String> stringToSignHandler, Context context) {
return new BlobSasImplUtil(blobServiceSasSignatureValues, getBlobContainerName())
.generateUserDelegationSas(userDelegationKey, accountName, context);
.generateUserDelegationSas(userDelegationKey, accountName, stringToSignHandler, context);
}

/**
Expand Down Expand Up @@ -1681,8 +1703,25 @@ public String generateSas(BlobServiceSasSignatureValues blobServiceSasSignatureV
* @return A {@code String} representing the SAS query parameters.
*/
public String generateSas(BlobServiceSasSignatureValues blobServiceSasSignatureValues, Context context) {
return generateSas(blobServiceSasSignatureValues, null, context);
}

/**
* Generates a service SAS for the container using the specified {@link BlobServiceSasSignatureValues}
* <p>Note : The client must be authenticated via {@link StorageSharedKeyCredential}
* <p>See {@link BlobServiceSasSignatureValues} for more information on how to construct a service SAS.</p>
*
* @param blobServiceSasSignatureValues {@link BlobServiceSasSignatureValues}
* @param stringToSignHandler For debugging purposes only. Returns the string to sign that was used to generate the
* signature.
* @param context Additional context that is passed through the code when generating a SAS.
*
* @return A {@code String} representing the SAS query parameters.
*/
public String generateSas(BlobServiceSasSignatureValues blobServiceSasSignatureValues,
Consumer<String> stringToSignHandler, Context context) {
return new BlobSasImplUtil(blobServiceSasSignatureValues, getBlobContainerName())
.generateSas(SasImplUtils.extractSharedKeyCredential(getHttpPipeline()), context);
.generateSas(SasImplUtils.extractSharedKeyCredential(getHttpPipeline()), stringToSignHandler, context);
}

private static boolean validateNoETag(BlobRequestConditions modifiedRequestConditions) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import java.time.OffsetDateTime;
import java.util.List;
import java.util.Map;
import java.util.function.Consumer;

import static com.azure.storage.common.implementation.StorageImplUtils.blockWithOptionalTimeout;

Expand Down Expand Up @@ -1125,8 +1126,29 @@ public String generateUserDelegationSas(BlobServiceSasSignatureValues blobServic
*/
public String generateUserDelegationSas(BlobServiceSasSignatureValues blobServiceSasSignatureValues,
UserDelegationKey userDelegationKey, String accountName, Context context) {
return generateUserDelegationSas(blobServiceSasSignatureValues, userDelegationKey, accountName,
null, context);
}

/**
* Generates a user delegation SAS for the container using the specified {@link BlobServiceSasSignatureValues}.
* <p>See {@link BlobServiceSasSignatureValues} for more information on how to construct a user delegation SAS.</p>
*
* @param blobServiceSasSignatureValues {@link BlobServiceSasSignatureValues}
* @param userDelegationKey A {@link UserDelegationKey} object used to sign the SAS values.
* See {@link BlobServiceClient#getUserDelegationKey(OffsetDateTime, OffsetDateTime)} for more information on
* how to get a user delegation key..
* @param accountName The account name.
* @param stringToSignHandler For debugging purposes only. Returns the string to sign that was used to generate the
* signature.
* @param context Additional context that is passed through the code when generating a SAS.
*
* @return A {@code String} representing the SAS query parameters.
*/
public String generateUserDelegationSas(BlobServiceSasSignatureValues blobServiceSasSignatureValues,
UserDelegationKey userDelegationKey, String accountName, Consumer<String> stringToSignHandler, Context context) {
return this.client.generateUserDelegationSas(blobServiceSasSignatureValues, userDelegationKey, accountName,
context);
stringToSignHandler, context);
}

/**
Expand Down Expand Up @@ -1182,6 +1204,24 @@ public String generateSas(BlobServiceSasSignatureValues blobServiceSasSignatureV
* @return A {@code String} representing the SAS query parameters.
*/
public String generateSas(BlobServiceSasSignatureValues blobServiceSasSignatureValues, Context context) {
return this.client.generateSas(blobServiceSasSignatureValues, context);
return generateSas(blobServiceSasSignatureValues, null, context);
}

/**
* Generates a service SAS for the container using the specified {@link BlobServiceSasSignatureValues}
* <p>Note : The client must be authenticated via {@link StorageSharedKeyCredential}
* <p>See {@link BlobServiceSasSignatureValues} for more information on how to construct a service SAS.</p>
*
* @param blobServiceSasSignatureValues {@link BlobServiceSasSignatureValues}
* @param stringToSignHandler For debugging purposes only. Returns the string to sign that was used to generate the
* signature.
* @param context Additional context that is passed through the code when generating a SAS.
*
* @return A {@code String} representing the SAS query parameters.
*/
public String generateSas(BlobServiceSasSignatureValues blobServiceSasSignatureValues,
Consumer<String> stringToSignHandler, Context context) {
return this.client.generateSas(blobServiceSasSignatureValues, stringToSignHandler, context);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
import java.util.List;
import java.util.Map;
import java.util.function.BiFunction;
import java.util.function.Consumer;
import java.util.stream.Collectors;

import static com.azure.core.util.FluxUtil.monoError;
Expand Down Expand Up @@ -1145,10 +1146,27 @@ public String generateAccountSas(AccountSasSignatureValues accountSasSignatureVa
* @return A {@code String} representing the SAS query parameters.
*/
public String generateAccountSas(AccountSasSignatureValues accountSasSignatureValues, Context context) {
return generateAccountSas(accountSasSignatureValues, null, context);
}

/**
* Generates an account SAS for the Azure Storage account using the specified {@link AccountSasSignatureValues}.
* <p>Note : The client must be authenticated via {@link StorageSharedKeyCredential}
* <p>See {@link AccountSasSignatureValues} for more information on how to construct an account SAS.</p>
*
* @param accountSasSignatureValues {@link AccountSasSignatureValues}
* @param stringToSignHandler For debugging purposes only. Returns the string to sign that was used to generate the
* signature.
* @param context Additional context that is passed through the code when generating a SAS.
*
* @return A {@code String} representing the SAS query parameters.
*/
public String generateAccountSas(AccountSasSignatureValues accountSasSignatureValues,
Consumer<String> stringToSignHandler, Context context) {
throwOnAnonymousAccess();
return new AccountSasImplUtil(accountSasSignatureValues,
this.encryptionScope == null ? null : this.encryptionScope.getEncryptionScope())
.generateSas(SasImplUtils.extractSharedKeyCredential(getHttpPipeline()), context);
.generateSas(SasImplUtils.extractSharedKeyCredential(getHttpPipeline()), stringToSignHandler, context);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import java.time.Duration;
import java.time.OffsetDateTime;
import java.util.Map;
import java.util.function.Consumer;

/**
* Client to a storage account. It may only be instantiated through a {@link BlobServiceClientBuilder}. This class does
Expand Down Expand Up @@ -765,7 +766,24 @@ public String generateAccountSas(AccountSasSignatureValues accountSasSignatureVa
* @return A {@code String} representing the SAS query parameters.
*/
public String generateAccountSas(AccountSasSignatureValues accountSasSignatureValues, Context context) {
return this.blobServiceAsyncClient.generateAccountSas(accountSasSignatureValues, context);
return generateAccountSas(accountSasSignatureValues, null, context);
}

/**
* Generates an account SAS for the Azure Storage account using the specified {@link AccountSasSignatureValues}.
* <p>Note : The client must be authenticated via {@link StorageSharedKeyCredential}
* <p>See {@link AccountSasSignatureValues} for more information on how to construct an account SAS.</p>
*
* @param accountSasSignatureValues {@link AccountSasSignatureValues}
* @param stringToSignHandler For debugging purposes only. Returns the string to sign that was used to generate the
* signature.
* @param context Additional context that is passed through the code when generating a SAS.
*
* @return A {@code String} representing the SAS query parameters.
*/
public String generateAccountSas(AccountSasSignatureValues accountSasSignatureValues,
Consumer<String> stringToSignHandler, Context context) {
return this.blobServiceAsyncClient.generateAccountSas(accountSasSignatureValues, stringToSignHandler, context);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,12 @@ public enum BlobServiceVersion implements ServiceVersion {
/**
* Service version {@code 2024-08-04}.
*/
V2024_08_04("2024-08-04");
V2024_08_04("2024-08-04"),

/**
* Service version {@code 2024-11-04}.
*/
V2024_11_04("2024-11-04");

private final String version;

Expand All @@ -144,6 +149,6 @@ public String getVersion() {
* @return the latest {@link BlobServiceVersion}
*/
public static BlobServiceVersion getLatest() {
return V2024_08_04;
return V2024_11_04;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import java.time.OffsetDateTime;
import java.util.Objects;
import java.util.function.Consumer;

import static com.azure.storage.common.implementation.SasImplUtils.formatQueryParameterDate;
import static com.azure.storage.common.implementation.SasImplUtils.tryAppendQueryParameter;
Expand Down Expand Up @@ -149,6 +150,20 @@ public BlobSasImplUtil(BlobServiceSasSignatureValues sasValues, String container
* @return A String representing the Sas
*/
public String generateSas(StorageSharedKeyCredential storageSharedKeyCredentials, Context context) {
return generateSas(storageSharedKeyCredentials, null, context);
}

/**
* Generates a Sas signed with a {@link StorageSharedKeyCredential}
*
* @param storageSharedKeyCredentials {@link StorageSharedKeyCredential}
* @param stringToSignHandler For debugging purposes only. Returns the string to sign that was used to generate the
* signature.
* @param context Additional context that is passed through the code when generating a SAS.
* @return The string to sign that will be used to generate the signature for the SAS URL.
*/
public String generateSas(StorageSharedKeyCredential storageSharedKeyCredentials,
Consumer<String> stringToSignHandler, Context context) {
StorageImplUtils.assertNotNull("storageSharedKeyCredentials", storageSharedKeyCredentials);

ensureState();
Expand All @@ -159,6 +174,10 @@ public String generateSas(StorageSharedKeyCredential storageSharedKeyCredentials
StorageImplUtils.logStringToSign(LOGGER, stringToSign, context);
final String signature = storageSharedKeyCredentials.computeHmac256(stringToSign);

if (stringToSignHandler != null) {
stringToSignHandler.accept(stringToSign);
}

return encode(null /* userDelegationKey */, signature);
}

Expand All @@ -171,6 +190,21 @@ public String generateSas(StorageSharedKeyCredential storageSharedKeyCredentials
* @return A String representing the Sas
*/
public String generateUserDelegationSas(UserDelegationKey delegationKey, String accountName, Context context) {
return generateUserDelegationSas(delegationKey, accountName, null, context);
}

/**
* Generates a Sas signed with a {@link UserDelegationKey}
*
* @param delegationKey {@link UserDelegationKey}
* @param accountName The account name
* @param stringToSignHandler For debugging purposes only. Returns the string to sign that was used to generate the
* signature.
* @param context Additional context that is passed through the code when generating a SAS.
* @return A String representing the Sas
*/
public String generateUserDelegationSas(UserDelegationKey delegationKey, String accountName,
Consumer<String> stringToSignHandler, Context context) {
StorageImplUtils.assertNotNull("delegationKey", delegationKey);
StorageImplUtils.assertNotNull("accountName", accountName);

Expand All @@ -182,6 +216,10 @@ public String generateUserDelegationSas(UserDelegationKey delegationKey, String
StorageImplUtils.logStringToSign(LOGGER, stringToSign, context);
String signature = StorageImplUtils.computeHMac256(delegationKey.getValue(), stringToSign);

if (stringToSignHandler != null) {
stringToSignHandler.accept(stringToSign);
}

return encode(delegationKey, signature);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@
import java.util.Set;
import java.util.concurrent.TimeoutException;
import java.util.function.BiFunction;
import java.util.function.Consumer;

import static com.azure.core.util.FluxUtil.fluxError;
import static com.azure.core.util.FluxUtil.monoError;
Expand Down Expand Up @@ -2456,9 +2457,30 @@ public String generateUserDelegationSas(BlobServiceSasSignatureValues blobServic
*/
public String generateUserDelegationSas(BlobServiceSasSignatureValues blobServiceSasSignatureValues,
UserDelegationKey userDelegationKey, String accountName, Context context) {
return generateUserDelegationSas(blobServiceSasSignatureValues, userDelegationKey, accountName,
null, context);
}

/**
* Generates a user delegation SAS for the blob using the specified {@link BlobServiceSasSignatureValues}.
* <p>See {@link BlobServiceSasSignatureValues} for more information on how to construct a user delegation SAS.</p>
*
* @param blobServiceSasSignatureValues {@link BlobServiceSasSignatureValues}
* @param userDelegationKey A {@link UserDelegationKey} object used to sign the SAS values.
* See {@link BlobServiceAsyncClient#getUserDelegationKey(OffsetDateTime, OffsetDateTime)} for more information on
* how to get a user delegation key.
* @param accountName The account name.
* @param stringToSignHandler For debugging purposes only. Returns the string to sign that was used to generate the
* signature.
* @param context Additional context that is passed through the code when generating a SAS.
*
* @return A {@code String} representing the SAS query parameters.
*/
public String generateUserDelegationSas(BlobServiceSasSignatureValues blobServiceSasSignatureValues,
UserDelegationKey userDelegationKey, String accountName, Consumer<String> stringToSignHandler, Context context) {
return new BlobSasImplUtil(blobServiceSasSignatureValues, getContainerName(), getBlobName(),
getSnapshotId(), getVersionId(), getEncryptionScope())
.generateUserDelegationSas(userDelegationKey, accountName, context);
.generateUserDelegationSas(userDelegationKey, accountName, stringToSignHandler, context);
}

/**
Expand Down Expand Up @@ -2514,9 +2536,26 @@ public String generateSas(BlobServiceSasSignatureValues blobServiceSasSignatureV
* @return A {@code String} representing the SAS query parameters.
*/
public String generateSas(BlobServiceSasSignatureValues blobServiceSasSignatureValues, Context context) {
return generateSas(blobServiceSasSignatureValues, null, context);
}

/**
* Generates a service SAS for the blob using the specified {@link BlobServiceSasSignatureValues}
* <p>Note : The client must be authenticated via {@link StorageSharedKeyCredential}
* <p>See {@link BlobServiceSasSignatureValues} for more information on how to construct a service SAS.</p>
*
* @param blobServiceSasSignatureValues {@link BlobServiceSasSignatureValues}
* @param stringToSignHandler For debugging purposes only. Returns the string to sign that was used to generate the
* signature.
* @param context Additional context that is passed through the code when generating a SAS.
*
* @return A {@code String} representing the SAS query parameters.
*/
public String generateSas(BlobServiceSasSignatureValues blobServiceSasSignatureValues,
Consumer<String> stringToSignHandler, Context context) {
return new BlobSasImplUtil(blobServiceSasSignatureValues, getContainerName(), getBlobName(),
getSnapshotId(), getVersionId(), getEncryptionScope())
.generateSas(SasImplUtils.extractSharedKeyCredential(getHttpPipeline()), context);
.generateSas(SasImplUtils.extractSharedKeyCredential(getHttpPipeline()), stringToSignHandler, context);
}

/**
Expand Down
Loading

0 comments on commit 046664f

Please sign in to comment.