12
12
// limitations under the License.
13
13
// ----------------------------------------------------------------------------------
14
14
15
- using System ;
16
- using System . Collections . Generic ;
17
- using System . Linq ;
18
-
19
15
using Azure . Identity ;
20
16
21
17
using Hyak . Common ;
24
20
using Microsoft . Azure . Commands . Common . Authentication . Abstractions . Extensions ;
25
21
using Microsoft . Azure . Commands . Common . Authentication . Abstractions . Interfaces ;
26
22
using Microsoft . Azure . Commands . Common . Authentication . Utilities ;
27
- using Microsoft . Azure . Commands . Shared . Config ;
28
23
using Microsoft . Azure . Internal . Subscriptions ;
29
24
using Microsoft . Azure . Internal . Subscriptions . Models ;
30
- using Microsoft . Azure . PowerShell . Common . Config ;
31
25
using Microsoft . Identity . Client ;
32
26
using Microsoft . Identity . Client . Broker ;
33
27
28
+ using System ;
29
+ using System . Collections . Generic ;
30
+ using System . Linq ;
31
+
34
32
namespace Microsoft . Azure . Commands . Common . Authentication
35
33
{
36
34
public abstract class PowerShellTokenCacheProvider
@@ -55,14 +53,14 @@ public virtual void FlushTokenData()
55
53
_tokenCacheDataToFlush = null ;
56
54
}
57
55
58
- public virtual void ClearCache ( )
56
+ public virtual void ClearCache ( string authority = null )
59
57
{
60
58
}
61
59
62
- public bool TryRemoveAccount ( string accountId )
60
+ public bool TryRemoveAccount ( string accountId , string authority = null )
63
61
{
64
62
TracingAdapter . Information ( string . Format ( "[AuthenticationClientFactory] Calling GetAccountsAsync" ) ) ;
65
- var client = CreatePublicClient ( ) ;
63
+ var client = CreatePublicClient ( authority ) ;
66
64
var account = client . GetAccountsAsync ( )
67
65
. ConfigureAwait ( false ) . GetAwaiter ( ) . GetResult ( )
68
66
. FirstOrDefault ( a => string . Equals ( a . Username , accountId , StringComparison . OrdinalIgnoreCase ) ) ;
@@ -89,7 +87,7 @@ public IEnumerable<IAccount> ListAccounts(string authority = null)
89
87
{
90
88
TracingAdapter . Information ( string . Format ( "[PowerShellTokenCacheProvider] Calling GetAccountsAsync on {0}" , authority ?? "AzureCloud" ) ) ;
91
89
92
- return CreatePublicClient ( authority : authority )
90
+ return CreatePublicClient ( authority )
93
91
. GetAccountsAsync ( )
94
92
. ConfigureAwait ( false ) . GetAwaiter ( ) . GetResult ( ) ;
95
93
}
@@ -195,18 +193,7 @@ public virtual IPublicClientApplication CreatePublicClient(string authority, str
195
193
/// </summary>
196
194
public virtual IPublicClientApplication CreatePublicClient ( string authority = null )
197
195
{
198
- var builder = PublicClientApplicationBuilder . Create ( Constants . PowerShellClientId ) ;
199
- if ( AzConfigReader . IsWamEnabled ( authority ) )
200
- {
201
- builder = builder . WithBroker ( new BrokerOptions ( BrokerOptions . OperatingSystems . Windows ) ) ;
202
- }
203
- if ( ! string . IsNullOrEmpty ( authority ) )
204
- {
205
- builder . WithAuthority ( authority ) ;
206
- }
207
- var client = builder . Build ( ) ;
208
- RegisterCache ( client ) ;
209
- return client ;
196
+ return CreatePublicClient ( authority , organizationTenant ) ;
210
197
}
211
198
212
199
public abstract TokenCachePersistenceOptions GetTokenCachePersistenceOptions ( ) ;
0 commit comments