Skip to content

Commit c7ef31c

Browse files
committed
source code copied from azure-storage-php for v1.3.0-queue release
1 parent 161eda4 commit c7ef31c

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.3.0
2+
* Added support for OAuth authentication.
3+
* Resolved some issues on Linux platform.
4+
15
2019.03 - version 1.2.0
26
* Documentation refinement.
37

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ QueueEndpoint=[myQueueEndpoint];SharedAccessSignature=[sasToken]
100100
```php
101101
$queueClient = QueueRestProxy::createQueueService($connectionString);
102102
```
103+
Or for AAD authentication:
104+
```php
105+
$queueClient = QueueRestProxy::createQueueServiceWithTokenCredential($token, $connectionString);
106+
```
103107
### Using Middlewares
104108
To specify the middlewares, user have to create an array with middlewares
105109
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-queue",
3-
"version": "1.2.0",
3+
"version": "1.3.0",
44
"description": "This project provides a set of PHP client libraries that make it easy to access Microsoft Azure Storage Queue APIs.",
55
"keywords": [ "php", "azure", "storage", "sdk", "queue" ],
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/Queue/Internal/QueueResources.php

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

44-
const QUEUE_SDK_VERSION = '1.2.0';
45-
const STORAGE_API_LATEST_VERSION = '2016-05-31';
44+
const QUEUE_SDK_VERSION = '1.3.0';
45+
const STORAGE_API_LATEST_VERSION = '2017-11-09';
4646

4747
// Error messages
4848
const INVALID_RECEIVE_MODE_MSG = 'The receive message option is in neither RECEIVE_AND_DELETE nor PEEK_LOCK mode.';

src/Queue/QueueRestProxy.php

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
use MicrosoftAzure\Storage\Common\Internal\Authentication\SharedAccessSignatureAuthScheme;
2828
use MicrosoftAzure\Storage\Common\Internal\Authentication\SharedKeyAuthScheme;
29+
use MicrosoftAzure\Storage\Common\Internal\Authentication\TokenAuthScheme;
2930
use MicrosoftAzure\Storage\Common\Internal\Http\HttpFormatter;
3031
use MicrosoftAzure\Storage\Common\Internal\Middlewares\CommonRequestMiddleware;
3132
use MicrosoftAzure\Storage\Common\Internal\Serialization\XmlSerializer;
@@ -132,6 +133,66 @@ public static function createQueueService(
132133
return $queueWrapper;
133134
}
134135

136+
/**
137+
* Builds a queue service object, it accepts the following
138+
* options:
139+
*
140+
* - http: (array) the underlying guzzle options. refer to
141+
* http://docs.guzzlephp.org/en/latest/request-options.html for detailed available options
142+
* - middlewares: (mixed) the middleware should be either an instance of a sub-class that
143+
* implements {@see MicrosoftAzure\Storage\Common\Middlewares\IMiddleware}, or a
144+
* `callable` that follows the Guzzle middleware implementation convention
145+
*
146+
* Please refer to
147+
* https://docs.microsoft.com/en-us/azure/storage/common/storage-auth-aad
148+
* for authenticate access to Azure blobs and queues using Azure Active Directory.
149+
*
150+
* @param string $token The bearer token passed as reference.
151+
* @param string $connectionString The configuration connection string.
152+
* @param array $options Array of options to pass to the service
153+
*
154+
* @return QueueRestProxy
155+
*/
156+
public static function createQueueServiceWithTokenCredential(
157+
&$token,
158+
$connectionString,
159+
array $options = []
160+
) {
161+
$settings = StorageServiceSettings::createFromConnectionStringForTokenCredential(
162+
$connectionString
163+
);
164+
165+
$primaryUri = Utilities::tryAddUrlScheme(
166+
$settings->getQueueEndpointUri()
167+
);
168+
169+
$secondaryUri = Utilities::tryAddUrlScheme(
170+
$settings->getQueueSecondaryEndpointUri()
171+
);
172+
173+
$queueWrapper = new QueueRestProxy(
174+
$primaryUri,
175+
$secondaryUri,
176+
$settings->getName(),
177+
$options
178+
);
179+
180+
// Getting authentication scheme
181+
$authScheme = new TokenAuthScheme(
182+
$token
183+
);
184+
185+
// Adding common request middleware
186+
$commonRequestMiddleware = new CommonRequestMiddleware(
187+
$authScheme,
188+
Resources::STORAGE_API_LATEST_VERSION,
189+
Resources::QUEUE_SDK_VERSION
190+
);
191+
$queueWrapper->pushMiddleware($commonRequestMiddleware);
192+
193+
return $queueWrapper;
194+
}
195+
135196
/**
136197
* Lists all queues in the storage account.
137198
*

0 commit comments

Comments
 (0)