Skip to content

Commit

Permalink
Upgrade common, implement getserviceclient credential, invoke listene…
Browse files Browse the repository at this point in the history
…r to be cleared (Azure#14073)
  • Loading branch information
VeryEarly authored Feb 1, 2021
1 parent 3f0d038 commit b1f6084
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 20 deletions.
1 change: 1 addition & 0 deletions src/Accounts/Accounts/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- Additional information about change #1
-->
## Upcoming Release
* Invoked on clear context listener in Azure session to be cleared when `Clear-AzContext` was executed

## Version 2.2.4
* Shown correct client request id on debug message [#13745]
Expand Down
3 changes: 2 additions & 1 deletion src/Accounts/Accounts/Context/ClearAzureRmContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

using System.IO;
using System.Management.Automation;

using Microsoft.Azure.Commands.Common.Authentication;
using Microsoft.Azure.Commands.Common.Authentication.Abstractions;
using Microsoft.Azure.Commands.Common.Authentication.Models;
Expand Down Expand Up @@ -86,6 +85,8 @@ void ClearContext(AzureRmProfile profile, RMProfileClient client)
}
}

AzureSession.Instance.RaiseContextClearedEvent();

if (PassThru.IsPresent)
{
WriteObject(result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ public string UserId

private readonly Func<string> _refresh;

public ExternalAccessToken(string token, Func<string> refresh = null)
public ExternalAccessToken(string accessToken, Func<string> renew = null)
{
this.AccessToken = token;
this._refresh = refresh;
this.AccessToken = accessToken;
this._refresh = renew;
}

public void AuthorizeRequest(Action<string, string> authTokenSetter)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,11 @@ public ServiceClientCredentials GetServiceClientCredentials(IAzureContext contex
}
}

public ServiceClientCredentials GetServiceClientCredentials(string accessToken, Func<string> renew = null)
{
return new RenewingTokenCredential(new ExternalAccessToken(accessToken, renew));
}

/// <summary>
/// Remove a user from token cache.
/// </summary>
Expand Down
32 changes: 16 additions & 16 deletions tools/Common.Netcore.Dependencies.targets
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@
<ItemGroup>
<PackageReference Include="Microsoft.Rest.ClientRuntime" Version="2.3.20"/>
<PackageReference Include="Microsoft.Rest.ClientRuntime.Azure" Version="3.3.19"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Aks" Version="1.3.30-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Authentication.Abstractions" Version="1.3.30-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Authorization" Version="1.3.30-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Common" Version="1.3.30-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Compute" Version="1.3.30-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Graph.Rbac" Version="1.3.30-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.KeyVault" Version="1.3.30-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Monitor" Version="1.3.30-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Network" Version="1.3.30-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.PolicyInsights" Version="1.3.30-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.ResourceManager" Version="1.3.30-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Storage" Version="1.3.30-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Storage.Management" Version="1.3.30-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Strategies" Version="1.3.30-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Websites" Version="1.3.30-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Aks" Version="1.3.31-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Authentication.Abstractions" Version="1.3.31-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Authorization" Version="1.3.31-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Common" Version="1.3.31-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Compute" Version="1.3.31-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Graph.Rbac" Version="1.3.31-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.KeyVault" Version="1.3.31-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Monitor" Version="1.3.31-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Network" Version="1.3.31-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.PolicyInsights" Version="1.3.31-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.ResourceManager" Version="1.3.31-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Storage" Version="1.3.31-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Storage.Management" Version="1.3.31-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Strategies" Version="1.3.31-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Websites" Version="1.3.31-preview"/>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Azure.Core" Version="1.7.0"/>
Expand All @@ -35,7 +35,7 @@
<PackageReference Include="PowerShellStandard.Library" Version="5.1.0" PrivateAssets="All" />
</ItemGroup>
<PropertyGroup>
<StorageToolsPath>$(NugetPackageRoot)\microsoft.azure.powershell.storage\1.3.30-preview\tools\</StorageToolsPath>
<StorageToolsPath>$(NugetPackageRoot)\microsoft.azure.powershell.storage\1.3.31-preview\tools\</StorageToolsPath>
</PropertyGroup>
<ItemGroup Condition="'$(OmitJsonPackage)' != 'true'">
<PackageReference Include="Newtonsoft.Json" Version="10.0.3"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ public Rest.ServiceClientCredentials GetServiceClientCredentials(IAzureContext c
throw new System.NotImplementedException();
}

public Rest.ServiceClientCredentials GetServiceClientCredentials(string accessToken, Func<string> renew = null)
{
throw new System.NotImplementedException();
}

public void RemoveUser(IAzureAccount account, IAzureTokenCache tokenCache)
{
throw new NotImplementedException();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,11 @@ public ServiceClientCredentials GetServiceClientCredentials(IAzureContext contex
return new Microsoft.Rest.TokenCredentials(Token.AccessToken);
}

public Rest.ServiceClientCredentials GetServiceClientCredentials(string accessToken, Func<string> renew = null)
{
throw new System.NotImplementedException();
}

public void RemoveUser(IAzureAccount account, IAzureTokenCache tokenCache)
{
throw new NotImplementedException();
Expand Down

0 comments on commit b1f6084

Please sign in to comment.