Skip to content

Commit

Permalink
source code copied from azure-storage-php for v1.3.0-queue release
Browse files Browse the repository at this point in the history
  • Loading branch information
vinjiang committed Apr 26, 2019
1 parent 161eda4 commit c7ef31c
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 4 deletions.
4 changes: 4 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
2019.04 - version 1.3.0
* Added support for OAuth authentication.
* Resolved some issues on Linux platform.

2019.03 - version 1.2.0
* Documentation refinement.

Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ QueueEndpoint=[myQueueEndpoint];SharedAccessSignature=[sasToken]
```php
$queueClient = QueueRestProxy::createQueueService($connectionString);
```
Or for AAD authentication:
```php
$queueClient = QueueRestProxy::createQueueServiceWithTokenCredential($token, $connectionString);
```
### Using Middlewares
To specify the middlewares, user have to create an array with middlewares
and put it in the `$requestOptions` with key 'middlewares'. The sequence of
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "microsoft/azure-storage-queue",
"version": "1.2.0",
"version": "1.3.0",
"description": "This project provides a set of PHP client libraries that make it easy to access Microsoft Azure Storage Queue APIs.",
"keywords": [ "php", "azure", "storage", "sdk", "queue" ],
"license": "MIT",
Expand All @@ -12,7 +12,7 @@
],
"require": {
"php": ">=5.6.0",
"microsoft/azure-storage-common": "~1.3.0"
"microsoft/azure-storage-common": "~1.4"
},
"autoload": {
"psr-4": {
Expand Down
4 changes: 2 additions & 2 deletions src/Queue/Internal/QueueResources.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ class QueueResources extends Resources
{
// @codingStandardsIgnoreStart

const QUEUE_SDK_VERSION = '1.2.0';
const STORAGE_API_LATEST_VERSION = '2016-05-31';
const QUEUE_SDK_VERSION = '1.3.0';
const STORAGE_API_LATEST_VERSION = '2017-11-09';

// Error messages
const INVALID_RECEIVE_MODE_MSG = 'The receive message option is in neither RECEIVE_AND_DELETE nor PEEK_LOCK mode.';
Expand Down
61 changes: 61 additions & 0 deletions src/Queue/QueueRestProxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

use MicrosoftAzure\Storage\Common\Internal\Authentication\SharedAccessSignatureAuthScheme;
use MicrosoftAzure\Storage\Common\Internal\Authentication\SharedKeyAuthScheme;
use MicrosoftAzure\Storage\Common\Internal\Authentication\TokenAuthScheme;
use MicrosoftAzure\Storage\Common\Internal\Http\HttpFormatter;
use MicrosoftAzure\Storage\Common\Internal\Middlewares\CommonRequestMiddleware;
use MicrosoftAzure\Storage\Common\Internal\Serialization\XmlSerializer;
Expand Down Expand Up @@ -132,6 +133,66 @@ public static function createQueueService(
return $queueWrapper;
}

/**
* Builds a queue service object, it accepts the following
* options:
*
* - http: (array) the underlying guzzle options. refer to
* http://docs.guzzlephp.org/en/latest/request-options.html for detailed available options
* - middlewares: (mixed) the middleware should be either an instance of a sub-class that
* implements {@see MicrosoftAzure\Storage\Common\Middlewares\IMiddleware}, or a
* `callable` that follows the Guzzle middleware implementation convention
*
* Please refer to
* https://docs.microsoft.com/en-us/azure/storage/common/storage-auth-aad
* for authenticate access to Azure blobs and queues using Azure Active Directory.
*
* @param string $token The bearer token passed as reference.
* @param string $connectionString The configuration connection string.
* @param array $options Array of options to pass to the service
*
* @return QueueRestProxy
*/
public static function createQueueServiceWithTokenCredential(
&$token,
$connectionString,
array $options = []
) {
$settings = StorageServiceSettings::createFromConnectionStringForTokenCredential(
$connectionString
);

$primaryUri = Utilities::tryAddUrlScheme(
$settings->getQueueEndpointUri()
);

$secondaryUri = Utilities::tryAddUrlScheme(
$settings->getQueueSecondaryEndpointUri()
);

$queueWrapper = new QueueRestProxy(
$primaryUri,
$secondaryUri,
$settings->getName(),
$options
);

// Getting authentication scheme
$authScheme = new TokenAuthScheme(
$token
);

// Adding common request middleware
$commonRequestMiddleware = new CommonRequestMiddleware(
$authScheme,
Resources::STORAGE_API_LATEST_VERSION,
Resources::QUEUE_SDK_VERSION
);
$queueWrapper->pushMiddleware($commonRequestMiddleware);

return $queueWrapper;
}

/**
* Lists all queues in the storage account.
*
Expand Down

0 comments on commit c7ef31c

Please sign in to comment.