Skip to content

Commit 5dceced

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents 0acc720 + ec859f6 commit 5dceced

File tree

722 files changed

+278424
-202122
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

722 files changed

+278424
-202122
lines changed

src/Accounts/Accounts/Az.Accounts.psd1

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -56,28 +56,27 @@ DotNetFrameworkVersion = '4.7.2'
5656
# RequiredModules = @()
5757

5858
# Assemblies that must be loaded prior to importing this module
59-
RequiredAssemblies = '.\Microsoft.Azure.PowerShell.Authentication.Abstractions.dll',
60-
'.\Microsoft.Azure.PowerShell.Authentication.dll',
61-
'.\Microsoft.Azure.PowerShell.Authentication.ResourceManager.dll',
62-
'.\Microsoft.Azure.PowerShell.Clients.Authorization.dll',
63-
'.\Microsoft.Azure.PowerShell.Clients.Compute.dll',
64-
'.\Microsoft.Azure.PowerShell.Clients.Graph.Rbac.dll',
65-
'.\Microsoft.Azure.PowerShell.Clients.Monitor.dll',
66-
'.\Microsoft.Azure.PowerShell.Clients.Network.dll',
67-
'.\Microsoft.Azure.PowerShell.Clients.ResourceManager.dll',
68-
'.\Microsoft.Azure.PowerShell.Common.dll',
69-
'.\Microsoft.Azure.PowerShell.Storage.dll',
70-
'.\Microsoft.Azure.PowerShell.Clients.Storage.Management.dll',
71-
'.\Microsoft.Azure.PowerShell.Clients.KeyVault.dll',
72-
'.\Microsoft.Azure.PowerShell.Clients.Websites.dll',
73-
'.\Hyak.Common.dll', '.\Microsoft.ApplicationInsights.dll',
74-
'.\Microsoft.Azure.Common.dll',
75-
'.\Microsoft.Rest.ClientRuntime.dll',
76-
'.\Microsoft.Rest.ClientRuntime.Azure.dll',
77-
'.\Microsoft.Rest.ClientRuntime.Azure.Authentication.dll',
78-
'.\Microsoft.WindowsAzure.Storage.dll',
79-
'.\Microsoft.WindowsAzure.Storage.DataMovement.dll',
80-
'.\Microsoft.Azure.PowerShell.Clients.Aks.dll',
59+
RequiredAssemblies = '.\Microsoft.Azure.PowerShell.Authentication.Abstractions.dll',
60+
'.\Microsoft.Azure.PowerShell.Authentication.dll',
61+
'.\Microsoft.Azure.PowerShell.Authentication.ResourceManager.dll',
62+
'.\Microsoft.Azure.PowerShell.Clients.Authorization.dll',
63+
'.\Microsoft.Azure.PowerShell.Clients.Compute.dll',
64+
'.\Microsoft.Azure.PowerShell.Clients.Graph.Rbac.dll',
65+
'.\Microsoft.Azure.PowerShell.Clients.Monitor.dll',
66+
'.\Microsoft.Azure.PowerShell.Clients.Network.dll',
67+
'.\Microsoft.Azure.PowerShell.Clients.ResourceManager.dll',
68+
'.\Microsoft.Azure.PowerShell.Common.dll',
69+
'.\Microsoft.Azure.PowerShell.Storage.dll',
70+
'.\Microsoft.Azure.PowerShell.Clients.Storage.Management.dll',
71+
'.\Microsoft.Azure.PowerShell.Clients.KeyVault.dll',
72+
'.\Microsoft.Azure.PowerShell.Clients.Websites.dll',
73+
'.\Hyak.Common.dll', '.\Microsoft.ApplicationInsights.dll',
74+
'.\Microsoft.Azure.Common.dll',
75+
'.\Microsoft.Rest.ClientRuntime.dll',
76+
'.\Microsoft.Rest.ClientRuntime.Azure.dll',
77+
'.\Microsoft.WindowsAzure.Storage.dll',
78+
'.\Microsoft.WindowsAzure.Storage.DataMovement.dll',
79+
'.\Microsoft.Azure.PowerShell.Clients.Aks.dll',
8180
'.\Microsoft.Azure.PowerShell.Strategies.dll'
8281

8382
# Script files (.ps1) that are run in the caller's environment prior to importing this module.

src/Accounts/Accounts/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
- Additional information about change #1
1919
-->
2020
## Upcoming Release
21+
* Update Authentication Library to fix ADFS issues with username/password auth
2122

2223
## Version 1.5.1
2324
* Update Uninstall-AzureRm to correctly delete modules in Mac

src/Accounts/Authentication/AdalLogger.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ namespace Microsoft.Azure.Commands.Common.Authentication
2222
/// Implements logging callback for ADAL - since only a single logger is allowed, allow
2323
/// reporting logs to multiple logging mechanisms
2424
/// </summary>
25-
public class AdalLogger : IAdalLogCallback, IDisposable
25+
public class AdalLogger : IDisposable
2626
{
2727
Action<string> _logger;
2828

@@ -74,7 +74,7 @@ public void Log(LogLevel level, string message)
7474
/// <summary>
7575
/// Central logging mechanism - allows registering multiple logging callbacks
7676
/// </summary>
77-
class AdalCompositeLogger : IAdalLogCallback
77+
class AdalCompositeLogger
7878
{
7979
static object _lockObject = new object();
8080
IList<AdalLogger> _loggers = new List<AdalLogger>();
@@ -96,7 +96,8 @@ internal static void Enable(AdalLogger logger)
9696
lock (_lockObject)
9797
{
9898
Instance._loggers.Add(logger);
99-
LoggerCallbackHandler.Callback = Instance;
99+
LoggerCallbackHandler.LogCallback = Instance.Log;
100+
LoggerCallbackHandler.PiiLoggingEnabled = true;
100101
}
101102
}
102103

@@ -129,7 +130,7 @@ internal static void Disable(AdalLogger logger)
129130
/// </summary>
130131
/// <param name="level">The log level</param>
131132
/// <param name="message">The log message</param>
132-
public void Log(LogLevel level, string message)
133+
public void Log(LogLevel level, string message, bool containsPII)
133134
{
134135
foreach (var logger in _loggers)
135136
{

src/Accounts/Authentication/Authentication.csproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
</PropertyGroup>
1313

1414
<ItemGroup>
15-
<PackageReference Include="Microsoft.Rest.ClientRuntime.Azure.Authentication" Version="2.3.5" />
16-
<PackageReference Include="Microsoft.IdentityModel.Clients.ActiveDirectory" Version="3.14.0" />
15+
<PackageReference Include="Microsoft.IdentityModel.Clients.ActiveDirectory" Version="3.19.2" />
1716
</ItemGroup>
1817

1918
</Project>

src/Accounts/Authentication/Authentication/CertificateApplicationCredentialProvider.cs

Lines changed: 0 additions & 59 deletions
This file was deleted.

src/Accounts/Authentication/Authentication/KeyStoreApplicationCredentialProvider.cs

Lines changed: 0 additions & 76 deletions
This file was deleted.

src/Accounts/Authentication/Authentication/ServicePrincipalTokenProvider.cs

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,7 @@
1515
using Hyak.Common;
1616
using Microsoft.Azure.Commands.Common.Authentication.Abstractions;
1717
using Microsoft.IdentityModel.Clients.ActiveDirectory;
18-
#if NETSTANDARD
19-
using Microsoft.Rest.Azure.Authentication;
2018
using Microsoft.WindowsAzure.Commands.Common;
21-
#endif
2219
using System;
2320
using System.Collections.Generic;
2421
using System.Security;
@@ -105,13 +102,8 @@ private AuthenticationResult AcquireTokenWithSecret(AdalConfiguration config, st
105102

106103
StoreAppKey(appId, config.AdDomain, appKey);
107104
var context = GetContext(config);
108-
#if !NETSTANDARD
109-
var credential = new ClientCredential(appId, appKey);
110-
return context.AcquireToken(config.ResourceClientUri, credential);
111-
#else
112105
var credential = new ClientCredential(appId, ConversionUtilities.SecureStringToString(appKey));
113106
return context.AcquireTokenAsync(config.ResourceClientUri, credential).ConfigureAwait(false).GetAwaiter().GetResult();
114-
#endif
115107
}
116108

117109
private AuthenticationResult AcquireTokenWithCertificate(
@@ -126,32 +118,20 @@ private AuthenticationResult AcquireTokenWithCertificate(
126118
}
127119

128120
var context = GetContext(config);
129-
#if !NETSTANDARD
130-
return context.AcquireToken(config.ResourceClientUri, new ClientAssertionCertificate(appId, certificate));
131-
#else
132121
return context.AcquireTokenAsync(config.ResourceClientUri, new Microsoft.IdentityModel.Clients.ActiveDirectory.ClientAssertionCertificate(appId, certificate))
133122
.ConfigureAwait(false).GetAwaiter().GetResult();
134-
#endif
135123
}
136124

137125
private AuthenticationResult RenewWithSecret(AdalConfiguration config, string appId)
138126
{
139127
TracingAdapter.Information(Resources.SPNRenewTokenTrace, appId, config.AdDomain, config.AdEndpoint,
140128
config.ClientId, config.ClientRedirectUri);
141-
#if !NETSTANDARD
142-
using (SecureString appKey = LoadAppKey(appId, config.AdDomain))
143-
{
144-
#else
145129
var appKey = LoadAppKey(appId, config.AdDomain);
146-
#endif
147130
if (appKey == null)
148131
{
149132
throw new KeyNotFoundException(string.Format(Resources.ServiceKeyNotFound, appId));
150133
}
151134
return AcquireTokenWithSecret(config, appId, appKey);
152-
#if !NETSTANDARD
153-
}
154-
#endif
155135
}
156136

157137
private AuthenticationResult RenewWithCertificate(
@@ -212,7 +192,7 @@ public void AuthorizeRequest(Action<string, string> authTokenSetter)
212192

213193
public string AccessToken { get { return AuthResult.AccessToken; } }
214194

215-
public string LoginType { get { return Authentication.LoginType.OrgId; } }
195+
public string LoginType { get { return Common.Authentication.LoginType.OrgId; } }
216196

217197
public string TenantId { get { return this.Configuration.AdDomain; } }
218198

src/Accounts/Authentication/Authentication/UserTokenProvider.Netcore.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414
using Hyak.Common;
15-
using Microsoft.Azure.Commands.Common.Authentication;
1615
using Microsoft.Azure.Commands.Common.Authentication.Abstractions;
1716
using Microsoft.IdentityModel.Clients.ActiveDirectory;
1817
using System;
@@ -276,9 +275,9 @@ public string LoginType
276275
{
277276
if (AuthResult.UserInfo.IdentityProvider != null)
278277
{
279-
return Authentication.LoginType.LiveId;
278+
return Common.Authentication.LoginType.LiveId;
280279
}
281-
return Authentication.LoginType.OrgId;
280+
return Common.Authentication.LoginType.OrgId;
282281
}
283282
}
284283

src/Accounts/Authentication/Factories/AuthenticationFactory.cs

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
using Microsoft.Azure.Commands.Common.Authentication.Abstractions;
1717
using Microsoft.IdentityModel.Clients.ActiveDirectory;
1818
using Microsoft.Rest;
19-
using Microsoft.Rest.Azure.Authentication;
2019
using System;
2120
using System.Linq;
2221
using System.Security;
@@ -335,13 +334,6 @@ public ServiceClientCredentials GetServiceClientCredentials(IAzureContext contex
335334
/*TracingAdapter.Information(Resources.UPNAuthenticationTokenTrace,
336335
token.LoginType, token.TenantId, token.UserId);*/
337336

338-
var env = new ActiveDirectoryServiceSettings
339-
{
340-
AuthenticationEndpoint = context.Environment.GetEndpointAsUri(AzureEnvironment.Endpoint.ActiveDirectory),
341-
TokenAudience = context.Environment.GetEndpointAsUri(context.Environment.GetTokenAudience(targetEndpoint)),
342-
ValidateAuthority = !context.Environment.OnPremise
343-
};
344-
345337
var tokenCache = AzureSession.Instance.TokenCache;
346338

347339
if (context.TokenCache != null)
@@ -361,33 +353,8 @@ public ServiceClientCredentials GetServiceClientCredentials(IAzureContext contex
361353
context.Environment.GetTokenAudience(targetEndpoint)));
362354
break;
363355
case AzureAccount.AccountType.User:
364-
result = Rest.Azure.Authentication.UserTokenProvider.CreateCredentialsFromCache(
365-
AdalConfiguration.PowerShellClientId,
366-
tenant,
367-
context.Account.Id,
368-
env,
369-
tokenCache as TokenCache).ConfigureAwait(false).GetAwaiter().GetResult();
370-
break;
371356
case AzureAccount.AccountType.ServicePrincipal:
372-
if (context.Account.IsPropertySet(AzureAccount.Property.CertificateThumbprint))
373-
{
374-
result = ApplicationTokenProvider.LoginSilentAsync(
375-
tenant,
376-
context.Account.Id,
377-
new CertificateApplicationCredentialProvider(
378-
context.Account.GetThumbprint()),
379-
env,
380-
tokenCache as TokenCache).ConfigureAwait(false).GetAwaiter().GetResult();
381-
}
382-
else
383-
{
384-
result = ApplicationTokenProvider.LoginSilentAsync(
385-
tenant,
386-
context.Account.Id,
387-
new KeyStoreApplicationCredentialProvider(tenant, KeyStore),
388-
env,
389-
tokenCache as TokenCache).ConfigureAwait(false).GetAwaiter().GetResult();
390-
}
357+
result = new RenewingTokenCredential(Authenticate(context.Account, context.Environment, tenant, null, ShowDialog.Never, null, context.Environment.GetTokenAudience(targetEndpoint)));
391358
break;
392359
default:
393360
throw new NotSupportedException(context.Account.Type.ToString());

0 commit comments

Comments
 (0)