-
Notifications
You must be signed in to change notification settings - Fork 4.8k
/
DefaultAzureCredentialFactory.cs
65 lines (53 loc) · 2.26 KB
/
DefaultAzureCredentialFactory.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
using Azure.Core;
namespace Azure.Identity
{
internal class DefaultAzureCredentialFactory
{
public DefaultAzureCredentialFactory(TokenCredentialOptions options)
: this(CredentialPipeline.GetInstance(options))
{ }
protected DefaultAzureCredentialFactory(CredentialPipeline pipeline)
{
Pipeline = pipeline;
}
public CredentialPipeline Pipeline { get; }
public virtual TokenCredential CreateEnvironmentCredential()
{
return new EnvironmentCredential(Pipeline);
}
public virtual TokenCredential CreateManagedIdentityCredential(string clientId)
{
return new ManagedIdentityCredential(clientId, Pipeline);
}
public virtual TokenCredential CreateSharedTokenCacheCredential(string tenantId, string username)
{
return new SharedTokenCacheCredential(tenantId, username, null, Pipeline);
}
public virtual TokenCredential CreateInteractiveBrowserCredential(string tenantId, string clientId)
{
return new InteractiveBrowserCredential(
tenantId,
clientId ?? Constants.DeveloperSignOnClientId,
new InteractiveBrowserCredentialOptions { TokenCachePersistenceOptions = new TokenCachePersistenceOptions() },
Pipeline);
}
public virtual TokenCredential CreateAzureCliCredential()
{
return new AzureCliCredential(Pipeline, default);
}
public virtual TokenCredential CreateVisualStudioCredential(string tenantId)
{
return new VisualStudioCredential(tenantId, Pipeline, default, default);
}
public virtual TokenCredential CreateVisualStudioCodeCredential(string tenantId)
{
return new VisualStudioCodeCredential(new VisualStudioCodeCredentialOptions { TenantId = tenantId }, Pipeline, default, default, default);
}
public virtual TokenCredential CreateAzurePowerShellCredential()
{
return new AzurePowerShellCredential(new AzurePowerShellCredentialOptions(), Pipeline, default);
}
}
}