Skip to content

Use Use Graph v2 NuGet package in Key Vault PowerShell instead of ref… #1618

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 11, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions setup/azurecmdfiles.wxi
Original file line number Diff line number Diff line change
Expand Up @@ -1226,6 +1226,9 @@
<Component Id="cmp8B8A7BBF33AC8748C36AF2D0F867CC3B" Guid="*">
<File Id="filF511C99CEA7C19431605AD07F44B545A" KeyPath="yes" Source="$(var.sourceDir)\ResourceManager\AzureResourceManager\AzureRM.KeyVault\Microsoft.ApplicationInsights.dll" />
</Component>
<Component Id="cmpBCA648A3B7B30300ACDCC83746172368" Guid="*">
<File Id="filD64CE679433518D6F65696BBFB22C420" KeyPath="yes" Source="$(var.sourceDir)\ResourceManager\AzureResourceManager\AzureRM.KeyVault\Microsoft.Azure.ActiveDirectory.GraphClient.dll" />
</Component>
<Component Id="cmpDBE0EFA9AB2C3936D498914505FD59BD" Guid="*">
<File Id="fil0EDC9091229822DEF09EFE500F63B7AC" KeyPath="yes" Source="$(var.sourceDir)\ResourceManager\AzureResourceManager\AzureRM.KeyVault\Microsoft.Azure.Commands.KeyVault.dll" />
</Component>
Expand Down Expand Up @@ -1289,6 +1292,15 @@
<Component Id="cmp1C7EFB238F49BC10B88911B4DD7CD760" Guid="*">
<File Id="filC52B079BABFAD11D6B89732C6569172A" KeyPath="yes" Source="$(var.sourceDir)\ResourceManager\AzureResourceManager\AzureRM.KeyVault\Microsoft.Azure.ResourceManager.dll" />
</Component>
<Component Id="cmpF469AE6EA612B0399957FAF85083221B" Guid="*">
<File Id="fil5684108D378817FBD69741594A1691AA" KeyPath="yes" Source="$(var.sourceDir)\ResourceManager\AzureResourceManager\AzureRM.KeyVault\Microsoft.Data.Edm.dll" />
</Component>
<Component Id="cmp28D6E7B5DF1FD9B79A5B4D16447379A1" Guid="*">
<File Id="fil5FFABBF4B17F9CB6DC30FB21B11A1B3F" KeyPath="yes" Source="$(var.sourceDir)\ResourceManager\AzureResourceManager\AzureRM.KeyVault\Microsoft.Data.OData.dll" />
</Component>
<Component Id="cmpCD008CF1C7D17EBD72102BD129C9372C" Guid="*">
<File Id="filAE03B936A9EEBD6BA395089F817FD5A0" KeyPath="yes" Source="$(var.sourceDir)\ResourceManager\AzureResourceManager\AzureRM.KeyVault\Microsoft.Data.Services.Client.dll" />
</Component>
<Component Id="cmpD542C61584E161A92D52490818D7E34A" Guid="*">
<File Id="filC47A710583991C8D624107A3F8EBDD72" KeyPath="yes" Source="$(var.sourceDir)\ResourceManager\AzureResourceManager\AzureRM.KeyVault\Microsoft.IdentityModel.Clients.ActiveDirectory.dll" />
</Component>
Expand Down Expand Up @@ -1328,6 +1340,9 @@
<Component Id="cmpD29EA01597258746011AE6EF9FC3D15A" Guid="*">
<File Id="filCE0262D8D43EF7AB4CDB25A0752B7121" KeyPath="yes" Source="$(var.sourceDir)\ResourceManager\AzureResourceManager\AzureRM.KeyVault\System.Net.Http.Primitives.dll" />
</Component>
<Component Id="cmp8EE8340753317C13D69F692E7E42B175" Guid="*">
<File Id="filAE60D28516977FE205BBEB3D15EB53DE" KeyPath="yes" Source="$(var.sourceDir)\ResourceManager\AzureResourceManager\AzureRM.KeyVault\System.Spatial.dll" />
</Component>
</Directory>
<Directory Id="dir76147B1D381C34B7638F2A844B5685DC" Name="AzureRM.Network">
<Component Id="cmp33F39A22183184A6B41F85DF085BAD29" Guid="*">
Expand Down Expand Up @@ -5204,6 +5219,7 @@
<ComponentRef Id="cmp007494D6DDD084F46271414EDBAE4A28" />
<ComponentRef Id="cmpF892ECD9E56A470DCBCDFB5721EFD871" />
<ComponentRef Id="cmp8B8A7BBF33AC8748C36AF2D0F867CC3B" />
<ComponentRef Id="cmpBCA648A3B7B30300ACDCC83746172368" />
<ComponentRef Id="cmpDBE0EFA9AB2C3936D498914505FD59BD" />
<ComponentRef Id="cmp3CD3D1820190A9634EFE76B4737874EB" />
<ComponentRef Id="cmp043B164F4D1039F8B2F62D774A383C9B" />
Expand All @@ -5225,6 +5241,9 @@
<ComponentRef Id="cmpD1A5B61C7046E3D9D8256C632EED70EF" />
<ComponentRef Id="cmpFD1FF637F9EDD0BF88DE235BB7C878F2" />
<ComponentRef Id="cmp1C7EFB238F49BC10B88911B4DD7CD760" />
<ComponentRef Id="cmpF469AE6EA612B0399957FAF85083221B" />
<ComponentRef Id="cmp28D6E7B5DF1FD9B79A5B4D16447379A1" />
<ComponentRef Id="cmpCD008CF1C7D17EBD72102BD129C9372C" />
<ComponentRef Id="cmpD542C61584E161A92D52490818D7E34A" />
<ComponentRef Id="cmp0EE8FCFA5508960593F3537443DACD4E" />
<ComponentRef Id="cmp6D51C798EDF35CEA322D396B85FB8E18" />
Expand All @@ -5238,6 +5257,7 @@
<ComponentRef Id="cmp8F99791178CB394FC285BF5F9DA21047" />
<ComponentRef Id="cmp55A0977CC2E4CD91F6738FFD78449307" />
<ComponentRef Id="cmpD29EA01597258746011AE6EF9FC3D15A" />
<ComponentRef Id="cmp8EE8340753317C13D69F692E7E42B175" />
<ComponentRef Id="cmp33F39A22183184A6B41F85DF085BAD29" />
<ComponentRef Id="cmp70B60DBD32D61BCA5715AB2D64131358" />
<ComponentRef Id="cmp92653399A1E9659661E74CA982C1D16A" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ private void Initialize()


#region New-AzureRmKeyVault

[Fact]
[Fact(Skip = "Graph authentication blocks test passes")]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestCreateNewVault()
{
Expand All @@ -63,8 +63,8 @@ public void TestCreateNewVault()
TestUtilities.GetCurrentMethodName()
);
}

[Fact]
[Fact(Skip = "Graph authentication blocks test passes")]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestCreateNewPremiumVaultEnabledForDeployment()
{
Expand Down Expand Up @@ -103,8 +103,8 @@ public void TestCreateVaultInUnknownResGrpFails()
TestUtilities.GetCurrentMethodName()
);
}

[Fact]
[Fact(Skip = "Graph authentication blocks test passes")]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestCreateVaultPositionalParams()
{
Expand All @@ -121,8 +121,8 @@ public void TestCreateVaultPositionalParams()
#endregion

#region Get-AzureRmKeyVault

[Fact]
[Fact(Skip = "Graph authentication blocks test passes")]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestGetVaultByNameAndResourceGroup()
{
Expand All @@ -136,7 +136,7 @@ public void TestGetVaultByNameAndResourceGroup()

}

[Fact]
[Fact(Skip = "Graph authentication blocks test passes")]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestGetVaultByNameAndResourceGroupPositionalParams()
{
Expand All @@ -150,7 +150,7 @@ public void TestGetVaultByNameAndResourceGroupPositionalParams()

}

[Fact]
[Fact(Skip = "Graph authentication blocks test passes")]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestGetVaultByName()
{
Expand All @@ -163,7 +163,7 @@ public void TestGetVaultByName()
);
}

[Fact]
[Fact(Skip = "Graph authentication blocks test passes")]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestGetVaultByNameCapitalized()
{
Expand Down Expand Up @@ -262,8 +262,8 @@ public void TestListVaultsByUnknownResourceGroupFails()
#endregion

#region Remove-AzureRmKeyVault

[Fact]
[Fact(Skip = "Graph authentication blocks test passes")]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestDeleteVaultByName()
{
Expand Down Expand Up @@ -292,8 +292,8 @@ public void TestDeleteUnknownVaultFails()
#endregion

#region Set-AzureRmKeyVaultAccessPolicy & Remove-AzureRmKeyVaultAccessPolicy
[Fact]

[Fact(Skip = "Graph authentication blocks test passes")]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestSetRemoveAccessPolicyByObjectId()
{
Expand All @@ -318,7 +318,7 @@ public void TestSetRemoveAccessPolicyByObjectId()
);
}

[Fact]
[Fact(Skip = "Graph authentication blocks test passes")]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestSetRemoveAccessPolicyByUPN()
{
Expand All @@ -340,7 +340,7 @@ public void TestSetRemoveAccessPolicyByUPN()
);
}

[Fact]
[Fact(Skip = "Graph authentication blocks test passes")]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestSetRemoveAccessPolicyByCompoundId()
{
Expand All @@ -367,7 +367,7 @@ public void TestSetRemoveAccessPolicyByCompoundId()
);
}

[Fact]
[Fact(Skip = "Graph authentication blocks test passes")]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestRemoveAccessPolicyWithCompoundIdPolicies()
{
Expand Down Expand Up @@ -397,7 +397,7 @@ public void TestRemoveAccessPolicyWithCompoundIdPolicies()
);
}

[Fact]
[Fact(Skip = "Graph authentication blocks test passes")]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestSetCompoundIdAccessPolicy()
{
Expand All @@ -424,8 +424,7 @@ public void TestSetCompoundIdAccessPolicy()
);
}


[Fact]
[Fact(Skip = "Graph authentication blocks test passes")]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestSetRemoveAccessPolicyBySPN()
{
Expand Down Expand Up @@ -461,7 +460,7 @@ public void TestSetRemoveAccessPolicyBySPN()
);
}

[Fact]
[Fact(Skip = "Graph authentication blocks test passes")]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestModifyAccessPolicy()
{
Expand All @@ -487,9 +486,8 @@ public void TestModifyAccessPolicy()
TestUtilities.GetCurrentMethodName()
);
}


[Fact]

[Fact(Skip = "Graph authentication blocks test passes")]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestModifyAccessPolicyEnabledForDeployment()
{
Expand All @@ -513,7 +511,7 @@ public void TestModifyAccessPolicyEnabledForDeployment()
}


[Fact]
[Fact(Skip = "Graph authentication blocks test passes")]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestModifyAccessPolicyEnabledForTemplateDeployment()
{
Expand All @@ -536,8 +534,7 @@ public void TestModifyAccessPolicyEnabledForTemplateDeployment()
);
}


[Fact]
[Fact(Skip = "Graph authentication blocks test passes")]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestModifyAccessPolicyEnabledForDiskEncryption()
{
Expand Down Expand Up @@ -584,7 +581,7 @@ public void TestModifyAccessPolicyNegativeCases()
);
}

[Fact]
[Fact(Skip = "Graph authentication blocks test passes")]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestRemoveNonExistentAccessPolicyDoesNotThrow()
{
Expand Down Expand Up @@ -612,7 +609,7 @@ public void TestRemoveNonExistentAccessPolicyDoesNotThrow()
#endregion

#region Piping
[Fact]
[Fact(Skip = "Graph authentication blocks test passes")]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestCreateDeleteVaultWithPiping()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@
<Reference Include="Hyak.Common">
<HintPath>..\..\..\packages\Hyak.Common.1.0.2\lib\portable-net403+win+wpa81\Hyak.Common.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.ActiveDirectory.GraphClient">
<HintPath>..\..\..\packages\Microsoft.Azure.ActiveDirectory.GraphClient.2.1.0\lib\portable-net4+sl5+win+wpa+wp8\Microsoft.Azure.ActiveDirectory.GraphClient.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.Common">
<HintPath>..\..\..\packages\Microsoft.Azure.Common.2.1.0\lib\net45\Microsoft.Azure.Common.dll</HintPath>
</Reference>
Expand Down Expand Up @@ -142,6 +145,15 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Resources.2.18.7-preview\lib\net40\Microsoft.Azure.ResourceManager.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Data.Edm">
<HintPath>..\..\..\packages\Microsoft.Data.Edm.5.6.4\lib\net40\Microsoft.Data.Edm.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Data.OData">
<HintPath>..\..\..\packages\Microsoft.Data.OData.5.6.4\lib\net40\Microsoft.Data.OData.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Data.Services.Client">
<HintPath>..\..\..\packages\Microsoft.Data.Services.Client.5.6.4\lib\net40\Microsoft.Data.Services.Client.dll</HintPath>
</Reference>
<Reference Include="Microsoft.IdentityModel.Clients.ActiveDirectory, Version=2.18.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.2.18.206251556\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.dll</HintPath>
<Private>True</Private>
Expand Down Expand Up @@ -187,6 +199,9 @@
<Reference Include="System.Net.Http.WebRequest" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Security" />
<Reference Include="System.Spatial">
<HintPath>..\..\..\packages\System.Spatial.5.6.4\lib\net40\System.Spatial.dll</HintPath>
</Reference>
<Reference Include="System.XML" />
<Reference Include="System.Xml.Linq" />
</ItemGroup>
Expand All @@ -212,6 +227,7 @@
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,27 @@ namespace Microsoft.Azure.Commands.KeyVault.Models
{
internal class DataServiceCredential
{
public DataServiceCredential(IAuthenticationFactory authFactory, AzureContext context)
public DataServiceCredential(IAuthenticationFactory authFactory, AzureContext context, AzureEnvironment.Endpoint resourceIdEndpoint)
{
if (authFactory == null)
throw new ArgumentNullException("authFactory");
if (context == null)
throw new ArgumentNullException("context");
var bundle = GetToken(authFactory, context);

var bundle = GetToken(authFactory, context, resourceIdEndpoint);
this.token = bundle.Item1;
}

public string AccessToken
{
get
{
return token.AccessToken;
}
}

public string TenantId { get; set; }

/// <summary>
/// Authentication callback method required by KeyVaultClient
/// </summary>
Expand All @@ -53,7 +63,7 @@ public Task<string> OnAuthentication(string authority, string resource, string s
return Task.FromResult<string>(tokenStr);
}

private Tuple<IAccessToken, string> GetToken(IAuthenticationFactory authFactory, AzureContext context)
private Tuple<IAccessToken, string> GetToken(IAuthenticationFactory authFactory, AzureContext context, AzureEnvironment.Endpoint resourceIdEndpoint)
{
if (context.Account == null)
throw new ArgumentException(KeyVaultProperties.Resources.ArmAccountNotFound);
Expand All @@ -62,24 +72,23 @@ private Tuple<IAccessToken, string> GetToken(IAuthenticationFactory authFactory,
context.Account.Type != AzureAccount.AccountType.ServicePrincipal )
throw new ArgumentException(string.Format(KeyVaultProperties.Resources.UnsupportedAccountType, context.Account.Type));

string tenant = null;
if (context.Subscription != null && context.Account != null)
tenant = context.Subscription.GetPropertyAsArray(AzureSubscription.Property.Tenants)
TenantId = context.Subscription.GetPropertyAsArray(AzureSubscription.Property.Tenants)
.Intersect(context.Account.GetPropertyAsArray(AzureAccount.Property.Tenants))
.FirstOrDefault();
if (tenant == null && context.Tenant != null && context.Tenant.Id != Guid.Empty)
tenant = context.Tenant.Id.ToString();
.FirstOrDefault();

if (string.IsNullOrWhiteSpace(TenantId) && context.Tenant != null && context.Tenant.Id != Guid.Empty)
TenantId = context.Tenant.Id.ToString();

if (string.IsNullOrWhiteSpace(tenant))
if (string.IsNullOrWhiteSpace(TenantId))
throw new ArgumentException(KeyVaultProperties.Resources.NoTenantInContext);

try
{
var accesstoken = authFactory.Authenticate(context.Account, context.Environment, tenant, null, ShowDialog.Auto,
ResourceIdEndpoint);
var accesstoken = authFactory.Authenticate(context.Account, context.Environment, TenantId, null, ShowDialog.Auto,
resourceIdEndpoint);

return Tuple.Create(accesstoken, context.Environment.Endpoints[ResourceIdEndpoint]);
return Tuple.Create(accesstoken, context.Environment.Endpoints[resourceIdEndpoint]);
}
catch (Exception ex)
{
Expand All @@ -88,6 +97,5 @@ private Tuple<IAccessToken, string> GetToken(IAuthenticationFactory authFactory,
}

private IAccessToken token;
private const AzureEnvironment.Endpoint ResourceIdEndpoint = AzureEnvironment.Endpoint.AzureKeyVaultServiceEndpointResourceId;
}
}
Loading