forked from Azure/azure-sdk-for-net
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moving ClientRuntime to azure dotnet sdk repo (#2401)
* 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
Showing
195 changed files
with
20,762 additions
and
32 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
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,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 |
128 changes: 128 additions & 0 deletions
128
...untime/Microsoft.Rest.ClientRuntime.Azure.Authentication/ActiveDirectoryClientSettings.cs
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,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 | ||
}; | ||
} | ||
|
||
|
||
} | ||
} |
88 changes: 88 additions & 0 deletions
88
...ntime/Microsoft.Rest.ClientRuntime.Azure.Authentication/ActiveDirectoryServiceSettings.cs
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,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; | ||
} | ||
} | ||
} |
Oops, something went wrong.