This repository has been archived by the owner on Nov 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 273
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Azure AD Support for Azure Media Services (#959)
* Update AMS API Version to 2.17 + Fix integration tests * Add AzureAD support (WIP) * Update samples and unit test to use Azure AD Service Princial authentication * Add User/Pass authentication + Access Token Cache * Update README.md * Fix typo * Fix typo * Remove old unit test + dead code * Updated README document of Azure Media Services samples to include Azure AD authentication scenarios * Fix MediaServicesSettings unit tests * Remove group annotation * Fix AuthenticationFilter unit tests
- Loading branch information
1 parent
0d3ce5b
commit 498a386
Showing
38 changed files
with
1,867 additions
and
753 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,12 @@ | ||
This folder contains the following Azure Media Service PHP SDK samples: | ||
This folder contains the following Azure Media Services PHP SDK samples: | ||
|
||
* vodworkflow_aes.php: End-to-end VOD workflow that applies AES content protection. | ||
* vodworkflow_drm_playready_widevine.php: End-to-end VOD workflow that applies DRM (PlayReady + Widevine) content protection. | ||
* vodworkflow_drm_fairplay.php: End-to-end VOD workflow that applies DRM (FairPlay) content protection. | ||
* scale_encoding_units.php: Scales the encoding reserved units. | ||
* analyticsworkflow_indexer.php: End-to-end analitycs workflow to index a media file. | ||
* liveworkflow_features.php: End-to-end live event workflow with configuration options to cover multiple scenarios. | ||
* azuread_userpass.php: Azure AD authentication with user credentials (username/password). | ||
* azuread_symmetrickey.php: Azure AD authentication with service principal (client symmetric key). | ||
* azuread_asymmetrickey: Azure AD authentication with service principal (client certificate). | ||
* userconfig.php: Common file used to store the Azure Media Services account credentials to execute all the samples. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<?php | ||
|
||
/** | ||
* LICENSE: Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0. | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* PHP version 5 | ||
* | ||
* @category Microsoft | ||
* | ||
* @author Azure PHP SDK <[email protected]> | ||
* @copyright 2012 Microsoft Corporation | ||
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0 | ||
* | ||
* @link https://github.com/windowsazure/azure-sdk-for-php | ||
*/ | ||
require_once __DIR__.'/../../vendor/autoload.php'; | ||
|
||
use WindowsAzure\Common\ServicesBuilder; | ||
use WindowsAzure\Common\Internal\MediaServicesSettings; | ||
use WindowsAzure\Common\Internal\Utilities; | ||
use WindowsAzure\MediaServices\MediaServicesRestProxy; | ||
use WindowsAzure\MediaServices\Authentication\AzureAdTokenCredentials; | ||
use WindowsAzure\MediaServices\Authentication\AzureAdClientAsymmetricKey; | ||
use WindowsAzure\MediaServices\Authentication\AzureAdTokenProvider; | ||
use WindowsAzure\MediaServices\Authentication\AzureEnvironments; | ||
use WindowsAzure\MediaServices\Models\Asset; | ||
|
||
// read user settings from config | ||
include_once 'userconfig.php'; | ||
|
||
echo "Azure SDK for PHP - AzureAD Asymmetric Key Authentication Sample".PHP_EOL; | ||
|
||
// 0 - Open the certificate file | ||
if ((!$cert_store = file_get_contents($pfxFileName)) || | ||
(!openssl_pkcs12_read($cert_store, $cert_info, $pfxPassword))) { | ||
echo "Error: Unable to read the cert file\n"; | ||
exit; | ||
} | ||
|
||
// 1 - Instantiate the credentials | ||
$credentials = new AzureAdTokenCredentials( | ||
$tenant, | ||
new AzureAdClientAsymmetricKey($clientId, $cert_info), | ||
AzureEnvironments::AZURE_CLOUD_ENVIRONMENT()); | ||
|
||
// 2 - Instantiate a token provider | ||
$provider = new AzureAdTokenProvider($credentials); | ||
|
||
// 3 - Connect to Azure Media Services | ||
$restProxy = ServicesBuilder::getInstance()->createMediaServicesService(new MediaServicesSettings($restApiEndpoint, $provider)); | ||
|
||
// 4 - List assets (sample operation) | ||
print('Listing Assets:' . PHP_EOL); | ||
foreach($restProxy->getAssetList() as $asset) | ||
{ | ||
print('Asset Id=' . $asset->getId() . ' Name=' . $asset->getName() . PHP_EOL); | ||
} |
Oops, something went wrong.