Skip to content

Commit 8310c2e

Browse files
committed
source code copied from azure-storage-php for v1.4.0-blob release
1 parent 6fcef8b commit 8310c2e

File tree

5 files changed

+73
-4
lines changed

5 files changed

+73
-4
lines changed

ChangeLog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
2019.04 - version 1.4.0
2+
* Added support for OAuth authentication.
3+
* Resolved some issues on Linux platform.
4+
15
2019.03 - version 1.3.0
26
* Fixed a bug where blob name '0' cannot be created.
37
* Documentation refinement.

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@ BlobEndpoint=[myBlobEndpoint];SharedAccessSignature=[sasToken]
101101
```php
102102
$blobClient = BlobRestProxy::createBlobService($connectionString);
103103
```
104+
Or for token authentication:
105+
```php
106+
$blobClient = BlobRestProxy::createBlobServiceWithTokenCredential($token, $connectionString);
107+
```
104108
### Using Middlewares
105109
To specify the middlewares, user have to create an array with middlewares
106110
and put it in the `$requestOptions` with key 'middlewares'. The sequence of

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "microsoft/azure-storage-blob",
3-
"version": "1.3.0",
3+
"version": "1.4.0",
44
"description": "This project provides a set of PHP client libraries that make it easy to access Microsoft Azure Storage Blob APIs.",
55
"keywords": [ "php", "azure", "storage", "sdk", "blob" ],
66
"license": "MIT",
@@ -12,7 +12,7 @@
1212
],
1313
"require": {
1414
"php": ">=5.6.0",
15-
"microsoft/azure-storage-common": "~1.3.0"
15+
"microsoft/azure-storage-common": "~1.4"
1616
},
1717
"autoload": {
1818
"psr-4": {

src/Blob/BlobRestProxy.php

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
use MicrosoftAzure\Storage\Blob\Models\SetBlobTierOptions;
7676
use MicrosoftAzure\Storage\Common\Internal\Authentication\SharedAccessSignatureAuthScheme;
7777
use MicrosoftAzure\Storage\Common\Internal\Authentication\SharedKeyAuthScheme;
78+
use MicrosoftAzure\Storage\Common\Internal\Authentication\TokenAuthScheme;
7879
use MicrosoftAzure\Storage\Common\Internal\Http\HttpFormatter;
7980
use MicrosoftAzure\Storage\Common\Internal\Middlewares\CommonRequestMiddleware;
8081
use MicrosoftAzure\Storage\Common\Internal\Serialization\XmlSerializer;
@@ -171,6 +172,66 @@ public static function createBlobService(
171172
return $blobWrapper;
172173
}
173174

175+
/**
176+
* Builds a blob service object, it accepts the following
177+
* options:
178+
*
179+
* - http: (array) the underlying guzzle options. refer to
180+
* http://docs.guzzlephp.org/en/latest/request-options.html for detailed available options
181+
* - middlewares: (mixed) the middleware should be either an instance of a sub-class that
182+
* implements {@see MicrosoftAzure\Storage\Common\Middlewares\IMiddleware}, or a
183+
* `callable` that follows the Guzzle middleware implementation convention
184+
*
185+
* Please refer to
186+
* https://docs.microsoft.com/en-us/azure/storage/common/storage-auth-aad
187+
* for authenticate access to Azure blobs and queues using Azure Active Directory.
188+
*
189+
* @param string $token The bearer token passed as reference.
190+
* @param string $connectionString The configuration connection string.
191+
* @param array $options Array of options to pass to the service
192+
*
193+
* @return BlobRestProxy
194+
*/
195+
public static function createBlobServiceWithTokenCredential(
196+
&$token,
197+
$connectionString,
198+
array $options = []
199+
) {
200+
$settings = StorageServiceSettings::createFromConnectionStringForTokenCredential(
201+
$connectionString
202+
);
203+
204+
$primaryUri = Utilities::tryAddUrlScheme(
205+
$settings->getBlobEndpointUri()
206+
);
207+
208+
$secondaryUri = Utilities::tryAddUrlScheme(
209+
$settings->getBlobSecondaryEndpointUri()
210+
);
211+
212+
$blobWrapper = new BlobRestProxy(
213+
$primaryUri,
214+
$secondaryUri,
215+
$settings->getName(),
216+
$options
217+
);
218+
219+
// Getting authentication scheme
220+
$authScheme = new TokenAuthScheme(
221+
$token
222+
);
223+
224+
// Adding common request middleware
225+
$commonRequestMiddleware = new CommonRequestMiddleware(
226+
$authScheme,
227+
Resources::STORAGE_API_LATEST_VERSION,
228+
Resources::BLOB_SDK_VERSION
229+
);
230+
$blobWrapper->pushMiddleware($commonRequestMiddleware);
231+
232+
return $blobWrapper;
233+
}
234+
174235
/**
175236
* Builds an anonymous access object with given primary service
176237
* endpoint. The service endpoint should contain a scheme and a

src/Blob/Internal/BlobResources.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ class BlobResources extends Resources
4141
{
4242
// @codingStandardsIgnoreStart
4343

44-
const BLOB_SDK_VERSION = '1.3.0';
45-
const STORAGE_API_LATEST_VERSION = '2017-04-17';
44+
const BLOB_SDK_VERSION = '1.4.0';
45+
const STORAGE_API_LATEST_VERSION = '2017-11-09';
4646

4747
// Error messages
4848
const INVALID_BTE_MSG = "The blob block type must exist in %s";

0 commit comments

Comments
 (0)