| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | using Azure.Core; |
| | 5 | |
|
| | 6 | | namespace Azure.Identity |
| | 7 | | { |
| | 8 | | internal class DefaultAzureCredentialFactory |
| | 9 | | { |
| | 10 | | public DefaultAzureCredentialFactory(TokenCredentialOptions options) |
| 148 | 11 | | : this(CredentialPipeline.GetInstance(options)) { } |
| | 12 | |
|
| 1186 | 13 | | protected DefaultAzureCredentialFactory(CredentialPipeline pipeline) |
| | 14 | | { |
| 1186 | 15 | | Pipeline = pipeline; |
| 1186 | 16 | | } |
| | 17 | |
|
| 1352 | 18 | | public CredentialPipeline Pipeline { get; } |
| | 19 | |
|
| | 20 | | public virtual TokenCredential CreateEnvironmentCredential() |
| | 21 | | { |
| 6 | 22 | | return new EnvironmentCredential(Pipeline); |
| | 23 | | } |
| | 24 | |
|
| | 25 | | public virtual TokenCredential CreateManagedIdentityCredential(string clientId) |
| | 26 | | { |
| 6 | 27 | | return new ManagedIdentityCredential(clientId, Pipeline); |
| | 28 | | } |
| | 29 | |
|
| | 30 | | public virtual TokenCredential CreateSharedTokenCacheCredential(string tenantId, string username) |
| | 31 | | { |
| 6 | 32 | | return new SharedTokenCacheCredential(tenantId, username, null, Pipeline); |
| | 33 | | } |
| | 34 | |
|
| | 35 | | public virtual TokenCredential CreateInteractiveBrowserCredential(string tenantId) |
| | 36 | | { |
| 4 | 37 | | return new InteractiveBrowserCredential(tenantId, Constants.DeveloperSignOnClientId, new InteractiveBrowserC |
| | 38 | | } |
| | 39 | |
|
| | 40 | | public virtual TokenCredential CreateAzureCliCredential() |
| | 41 | | { |
| 6 | 42 | | return new AzureCliCredential(Pipeline, default); |
| | 43 | | } |
| | 44 | |
|
| | 45 | | public virtual TokenCredential CreateVisualStudioCredential(string tenantId) |
| | 46 | | { |
| 6 | 47 | | return new VisualStudioCredential(tenantId, Pipeline, default, default); |
| | 48 | | } |
| | 49 | |
|
| | 50 | | public virtual TokenCredential CreateVisualStudioCodeCredential(string tenantId) |
| | 51 | | { |
| 6 | 52 | | return new VisualStudioCodeCredential(new VisualStudioCodeCredentialOptions { TenantId = tenantId }, Pipelin |
| | 53 | | } |
| | 54 | | } |
| | 55 | | } |