Skip to content

Commit

Permalink
Moving ClientRuntime to azure dotnet sdk repo (#2401)
Browse files Browse the repository at this point in the history
* Moving ClientRuntime to azure dotnet sdk repo
* adding tests
* temp
* fixing ci
* undoing commenting
* undoing 2
* merged latest changes
* using win sdk exec paths
* Unused comments
* fixing assemblyinfo
* Fixing Packaging of ClientRuntime projects
* minor fix
* adding msging
* verbose pack
* Fixing signing ci builds
* tweak build script
* synced changes from AutoRest/master and fixed build proj
* removed superflous brace
* fixing test?
* adding slns for individual client runtime projects to allow individual build/publish
  • Loading branch information
dsgouda authored and Hovsep committed Oct 14, 2016
1 parent 1eb59dc commit 7c79d8a
Show file tree
Hide file tree
Showing 195 changed files with 20,762 additions and 32 deletions.
38 changes: 36 additions & 2 deletions build.proj
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@
<LibrariesToBuild Include="$(LibrarySourceFolder)\**\*.sln" Condition=" '$(Scope)' == 'all' " />
<LibraryFxTargetList Include="$(FxTargetList)" />
<AutoRestLibraryFxTargetList Include="portable;net45" />
<ClientRuntimeProjects Include="$(LibrarySourceFolder)\ClientRuntime\**\*.xproj" />
<ClientRuntimeTests Include="$(LibrarySourceFolder)\ClientRuntime\*.Tests\*.xproj" />
</ItemGroup>

<PropertyGroup>
Expand All @@ -77,6 +79,34 @@
<UsingTask TaskName="ValidateStrongNameSignatureTask" AssemblyFile="$(LibraryToolsFolder)\Microsoft.WindowsAzure.Build.Tasks.dll" />
<UsingTask TaskName="FilterOutAutoRestLibraries" AssemblyFile="$(LibraryToolsFolder)\Microsoft.WindowsAzure.Build.Tasks.dll" />

<!-- Building ClientRuntime projects -->
<Target Name="BuildClientRuntime">
<Exec Command="dotnet restore" WorkingDirectory="%(ClientRuntimeProjects.RootDir)\%(ClientRuntimeProjects.Directory)"/>
<Exec Command="dotnet build --configuration $(Configuration)" WorkingDirectory="%(ClientRuntimeProjects.RootDir)\%(ClientRuntimeProjects.Directory)"/>
</Target>

<Target Name="DisableSN" >
<!-- Check for admin privs -->
<Exec Command="net session" IgnoreExitCode="true" StandardErrorImportance="Low">
<Output PropertyName="isadmin" TaskParameter="ExitCode" />
</Exec>

<!-- Disable strong name checking -->
<Exec Command='"C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools\sn.exe" -Vr *' Condition="$(isadmin) == 0"/>
<Exec Command='"C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools\x64\sn.exe" -Vr *' Condition="$(isadmin) == 0"/>
</Target>

<Target Name="EnableSN" >
<!-- Check for admin privs -->
<Exec Command="net session" IgnoreExitCode="true" StandardErrorImportance="Low">
<Output PropertyName="isadmin" TaskParameter="ExitCode" />
</Exec>

<!-- Enable strong name checking -->
<Exec Command='$(WindowsSDK_ExecutablePath_x86)\sn.exe -Vx *' Condition="$(isadmin) == 0"/>
<Exec Command='$(WindowsSDK_ExecutablePath_x64)\sn.exe -Vx *' Condition="$(isadmin) == 0"/>
</Target>

<!--
CI build related
-->
Expand Down Expand Up @@ -109,13 +139,15 @@
<Exec
Command="$(LibraryToolsFolder)\AzCopy\AzCopy.exe /Source:https://azuresdktools.blob.core.windows.net/7-zip /S /Dest:$(ZipExeFolder) /Y"
Condition="!Exists('$(ZipExe)')" />

</Target>

<Target Name="Build" DependsOnTargets="BuildMsBuildTask;PrepareForAutoRestLibraries;RestoreNugetPackages">
<Target Name="Build" DependsOnTargets="BuildClientRuntime;BuildMsBuildTask;PrepareForAutoRestLibraries;RestoreNugetPackages">
<PropertyGroup>
<_ExtraPropertyList>CodeSign=$(CodeSign)</_ExtraPropertyList>
<_TemporaryNetCoreFeeds>-s https://api.nuget.org/v3/index.json -s https://dotnet.myget.org/F/cli-deps/api/v3/index.json</_TemporaryNetCoreFeeds>
</PropertyGroup>
<CallTarget Targets="DisableSN" Condition=" '$(OS)' == 'Windows_NT'"/>
<CallTarget Targets="BuildServerPreparation" Condition=" '$(CodeSign)' == 'true' " />

<MSBuild Projects="@(NonAutoRestLibraries)"
Expand Down Expand Up @@ -167,11 +199,13 @@
<Exec Command="$(LibraryNugetPackageFolder)\xunit.runner.console.2.0.0\tools\xunit.console.x86.exe &quot;%(TestDlls.Identity)&quot; -html &quot;$(MSBuildProjectDirectory)\TestResults\%(TestDlls.Filename).html&quot;"
Condition=" '@(TestDlls)' != '' "
ContinueOnError="false"/>

<!--Based on https://github.com/xunit/xunit/issues/653, only xml is supported -->
<Exec Command="dotnet test -xml &quot;$(MSBuildProjectDirectory)\TestResults\%(NetCore_AutoRestLibraries.Filename).xml&quot;"
WorkingDirectory="%(NetCore_AutoRestLibraries.Test)"
Condition=" @(NetCore_AutoRestLibraries) != '' and '%(NetCore_AutoRestLibraries.Test)' != '' "/>
<Exec Command="dotnet test -xml &quot;$(MSBuildProjectDirectory)\TestResults\%(ClientRuntimeTests.Filename).xml&quot;"
WorkingDirectory="%(ClientRuntimeTests.RootDir)\%(ClientRuntimeTests.Directory)"/>
</Target>

<PropertyGroup>
Expand Down
1 change: 1 addition & 0 deletions global.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"projects": [
"src/ClientRuntime",
"src/KeyVault",
"src/TestFramework/Microsoft.Azure.Test.HttpRecorder",
"src/TestFramework/Microsoft.Rest.ClientRuntime.Azure.TestFramework",
Expand Down
64 changes: 64 additions & 0 deletions src/ClientRuntime/ClientRuntime.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Rest.ClientRuntime", "Microsoft.Rest.ClientRuntime\Microsoft.Rest.ClientRuntime.xproj", "{EDDB6367-5C7B-428C-B54C-96BCD90F6E6C}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Rest.ClientRuntime.Azure.Authentication", "Microsoft.Rest.ClientRuntime.Azure.Authentication\Microsoft.Rest.ClientRuntime.Azure.Authentication.xproj", "{6319205D-BBFC-4150-BEAE-31B1C9B911DD}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Rest.ClientRuntime.Azure", "Microsoft.Rest.ClientRuntime.Azure\Microsoft.Rest.ClientRuntime.Azure.xproj", "{D5296EAB-C13E-4A88-9532-BD0677D18EC9}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Rest.ClientRuntime.Azure.Tests", "Microsoft.Rest.ClientRuntime.Azure.Tests\Microsoft.Rest.ClientRuntime.Azure.Tests.xproj", "{3B2346E5-5D1F-4B0A-AEEE-F3AFB9583A72}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Rest.ClientRuntime.Etw", "Microsoft.Rest.ClientRuntime.Etw\Microsoft.Rest.ClientRuntime.Etw.xproj", "{218D7297-8254-4C70-9C04-33C3D5EE9709}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Rest.ClientRuntime.Log4Net", "Microsoft.Rest.ClientRuntime.Log4Net\Microsoft.Rest.ClientRuntime.Log4Net.xproj", "{348E414F-101A-4939-99FF-2C994A965A89}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Rest.ClientRuntime.Tests", "Microsoft.Rest.ClientRuntime.Tests\Microsoft.Rest.ClientRuntime.Tests.xproj", "{F7F20E35-43EE-4FCC-BF83-7BF93B192BC8}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Rest.ClientRuntime.Tracing.Tests", "Microsoft.Rest.ClientRuntime.Tracing.Tests\Microsoft.Rest.ClientRuntime.Tracing.Tests.xproj", "{52C61F15-BF86-41DC-93D1-05D3DA70F032}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{EDDB6367-5C7B-428C-B54C-96BCD90F6E6C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EDDB6367-5C7B-428C-B54C-96BCD90F6E6C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EDDB6367-5C7B-428C-B54C-96BCD90F6E6C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EDDB6367-5C7B-428C-B54C-96BCD90F6E6C}.Release|Any CPU.Build.0 = Release|Any CPU
{6319205D-BBFC-4150-BEAE-31B1C9B911DD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6319205D-BBFC-4150-BEAE-31B1C9B911DD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6319205D-BBFC-4150-BEAE-31B1C9B911DD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6319205D-BBFC-4150-BEAE-31B1C9B911DD}.Release|Any CPU.Build.0 = Release|Any CPU
{D5296EAB-C13E-4A88-9532-BD0677D18EC9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D5296EAB-C13E-4A88-9532-BD0677D18EC9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D5296EAB-C13E-4A88-9532-BD0677D18EC9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D5296EAB-C13E-4A88-9532-BD0677D18EC9}.Release|Any CPU.Build.0 = Release|Any CPU
{3B2346E5-5D1F-4B0A-AEEE-F3AFB9583A72}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3B2346E5-5D1F-4B0A-AEEE-F3AFB9583A72}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3B2346E5-5D1F-4B0A-AEEE-F3AFB9583A72}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3B2346E5-5D1F-4B0A-AEEE-F3AFB9583A72}.Release|Any CPU.Build.0 = Release|Any CPU
{218D7297-8254-4C70-9C04-33C3D5EE9709}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{218D7297-8254-4C70-9C04-33C3D5EE9709}.Debug|Any CPU.Build.0 = Debug|Any CPU
{218D7297-8254-4C70-9C04-33C3D5EE9709}.Release|Any CPU.ActiveCfg = Release|Any CPU
{218D7297-8254-4C70-9C04-33C3D5EE9709}.Release|Any CPU.Build.0 = Release|Any CPU
{348E414F-101A-4939-99FF-2C994A965A89}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{348E414F-101A-4939-99FF-2C994A965A89}.Debug|Any CPU.Build.0 = Debug|Any CPU
{348E414F-101A-4939-99FF-2C994A965A89}.Release|Any CPU.ActiveCfg = Release|Any CPU
{348E414F-101A-4939-99FF-2C994A965A89}.Release|Any CPU.Build.0 = Release|Any CPU
{F7F20E35-43EE-4FCC-BF83-7BF93B192BC8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F7F20E35-43EE-4FCC-BF83-7BF93B192BC8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F7F20E35-43EE-4FCC-BF83-7BF93B192BC8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F7F20E35-43EE-4FCC-BF83-7BF93B192BC8}.Release|Any CPU.Build.0 = Release|Any CPU
{52C61F15-BF86-41DC-93D1-05D3DA70F032}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{52C61F15-BF86-41DC-93D1-05D3DA70F032}.Debug|Any CPU.Build.0 = Debug|Any CPU
{52C61F15-BF86-41DC-93D1-05D3DA70F032}.Release|Any CPU.ActiveCfg = Release|Any CPU
{52C61F15-BF86-41DC-93D1-05D3DA70F032}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.

using System;
using Microsoft.IdentityModel.Clients.ActiveDirectory;
using Microsoft.Rest.ClientRuntime.Azure.Authentication.Properties;

namespace Microsoft.Rest.Azure.Authentication
{
/// <summary>
/// Settings for authentication with an Azure or Azure Stack service using Active Directory.
/// </summary>
public sealed class ActiveDirectoryClientSettings
{
/// <summary>
/// Query string allowing use of cookies in user login dialog
/// </summary>
public const string EnableEbdMagicCookie = "site_id=501358&display=popup";

#if !PORTABLE
/// <summary>
/// Gets or sets prompt behavior.
/// </summary>
public PromptBehavior PromptBehavior { get; set; }
#endif

/// <summary>
/// Gets or sets owner window.
/// </summary>
public object OwnerWindow { get; set; }

/// <summary>
/// Additional query parameters sent with the AD request
/// </summary>
public string AdditionalQueryParameters { get; set; }

/// <summary>
/// The active directory client id for this application.
/// </summary>
public string ClientId { get; set; }

/// <summary>
/// The client redirect uri associated with this application.
/// </summary>
public Uri ClientRedirectUri { get; set; }

/// <summary>
/// Initializes default active directory dialog parameters.
/// </summary>
public ActiveDirectoryClientSettings()
{
#if !PORTABLE
this.PromptBehavior = PromptBehavior.Auto;
#endif
this.AdditionalQueryParameters = EnableEbdMagicCookie;
}

/// <summary>
/// Initializes active directory client settings with the application specific properties
/// for client id and client redirect uri.
/// See <see href="https://azure.microsoft.com/en-us/documentation/articles/active-directory-devquickstarts-dotnet/">Active Directory Quickstart for .Net</see>
/// for detailed instructions on creating an Azure Active Directory application.
/// </summary>
/// <param name="clientId">The active directory client id.</param>
/// <param name="clientRedirectUri">The client redirect uri defined for this application in active directory.</param>
public ActiveDirectoryClientSettings(string clientId, Uri clientRedirectUri) : this()
{
this.ClientId = clientId;
this.ClientRedirectUri = clientRedirectUri;
}

/// <summary>
/// Returns active directory cient settings that suppress user credential prompts. Authentication
/// will succeed if and only if previous authentication results are cached in the TokenCache or
/// client cookies.
/// </summary>
/// <param name="clientId">The client Id associated with this active directory application.</param>
/// <param name="clientRedirectUri">The client redirect Uri associated with this active directory application.</param>
/// <returns>active directory client settings that suppress user credential prompts.</returns>
public static ActiveDirectoryClientSettings UseCacheOrCookiesOnly(string clientId, Uri clientRedirectUri)
{
return new ActiveDirectoryClientSettings(clientId, clientRedirectUri)
{
#if !PORTABLE
PromptBehavior = PromptBehavior.Never,
#endif
};
}

/// <summary>
/// Returns active directory client settings that prompt the user for credentials only when
/// no matching cookies or cached tokens are found. Authentication will succeed if valid cookies
/// or cached tokens are found, or, if no valid tokens are found, the user enters valid
/// active directory user credentials.
/// </summary>
/// <param name="clientId">The client Id associated with this active directory application.</param>
/// <param name="clientRedirectUri">The client redirect Uri associated with this active directory application.</param>
/// <returns>Settings that prefer cached tokens or cookies over user prompting.</returns>
public static ActiveDirectoryClientSettings UseCacheCookiesOrPrompt(string clientId, Uri clientRedirectUri)
{
return new ActiveDirectoryClientSettings(clientId , clientRedirectUri)
{
#if !PORTABLE
PromptBehavior = PromptBehavior.Auto,
#endif
};
}

/// <summary>
/// Ignore authentication cookies or cached tokens and force the user to enter valid credentials.
/// Authentication will succeed if and only if the user enters valid credentials.
/// </summary>
/// <param name="clientId">The client Id associated with this active directory application.</param>
/// <param name="clientRedirectUri">The client redirect Uri associated with this active directory application.</param>
/// <returns>Settings that require the user to input credentials,</returns>
public static ActiveDirectoryClientSettings UsePromptOnly(string clientId, Uri clientRedirectUri)
{
return new ActiveDirectoryClientSettings(clientId, clientRedirectUri)
{
#if !PORTABLE
PromptBehavior = PromptBehavior.Always
#endif
};
}


}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.

using System;
using Microsoft.IdentityModel.Clients.ActiveDirectory;
using Microsoft.Rest.ClientRuntime.Azure.Authentication.Properties;

namespace Microsoft.Rest.Azure.Authentication
{
/// <summary>
/// Settings for authentication with an Azure or Azure Stack service using Active Directory.
/// </summary>
public sealed class ActiveDirectoryServiceSettings
{
private Uri _authenticationEndpoint;

private static readonly ActiveDirectoryServiceSettings AzureSettings = new ActiveDirectoryServiceSettings
{
AuthenticationEndpoint= new Uri("https://login.windows.net/"),
TokenAudience = new Uri("https://management.core.windows.net/"),
ValidateAuthority = true
};

private static readonly ActiveDirectoryServiceSettings AzureChinaSettings = new ActiveDirectoryServiceSettings
{
AuthenticationEndpoint= new Uri("https://login.chinacloudapi.cn/"),
TokenAudience = new Uri("https://management.core.chinacloudapi.cn/"),
ValidateAuthority = true
};

/// <summary>
/// Gets the serviceSettings for authentication with Azure
/// </summary>
public static ActiveDirectoryServiceSettings Azure { get { return AzureSettings; } }

/// <summary>
/// Gets the serviceSettings for authentication with Azure China
/// </summary>
public static ActiveDirectoryServiceSettings AzureChina { get { return AzureChinaSettings; } }

/// <summary>
/// Gets or sets the ActiveDirectory Endpoint for the Azure Environment
/// </summary>
public Uri AuthenticationEndpoint
{
get { return _authenticationEndpoint; }
set { _authenticationEndpoint = EnsureTrailingSlash(value); }
}

/// <summary>
/// Gets or sets the Token audience for an endpoint
/// </summary>
public Uri TokenAudience { get; set; }

/// <summary>
/// Gets or sets a value that determines whether the authentication endpoint should be validated with Azure AD
/// </summary>
public bool ValidateAuthority { get; set; }

private static Uri EnsureTrailingSlash(Uri authenticationEndpoint)
{
if (authenticationEndpoint == null)
{
throw new ArgumentNullException("authenticationEndpoint");
}

UriBuilder builder = new UriBuilder(authenticationEndpoint);
if (!string.IsNullOrEmpty(builder.Query))
{
throw new ArgumentOutOfRangeException(nameof(authenticationEndpoint),
Resources.AuthenticationEndpointContainsQuery);
}

var path = builder.Path;
if (string.IsNullOrWhiteSpace(path))
{
path = "/";
}
else if (!path.EndsWith("/", StringComparison.Ordinal))
{
path = path + "/";
}

builder.Path = path;
return builder.Uri;
}
}
}
Loading

0 comments on commit 7c79d8a

Please sign in to comment.