Skip to content

Commit

Permalink
Merge pull request #20 from Anders-Toegersen/feature/azurecredentialo…
Browse files Browse the repository at this point in the history
…ptionsprovider

Introduced IAzureCredentialOptionsProvider
  • Loading branch information
Anders-Toegersen authored Jan 17, 2023
2 parents da1e040 + 91f4487 commit ed9b1f9
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Atc.Azure.Options/GlobalUsings.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
global using Atc.Azure.Options.Authorization;
global using Atc.Azure.Options.Cosmos;
global using Atc.Azure.Options.Environment;
global using Atc.Azure.Options.Providers;
Expand Down
24 changes: 24 additions & 0 deletions src/Atc.Azure.Options/Providers/AzureCredentialOptionsProvider.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
namespace Atc.Azure.Options.Providers;

public class AzureCredentialOptionsProvider : IAzureCredentialOptionsProvider
{
public DefaultAzureCredentialOptions GetAzureCredentialOptions(
EnvironmentOptions environmentOptions,
ClientAuthorizationOptions authorizationOptions)
=> GetAzureCredentialOptions(environmentOptions, authorizationOptions.TenantId);

public DefaultAzureCredentialOptions GetAzureCredentialOptions(
EnvironmentOptions environmentOptions,
string tenantId)
=> new DefaultAzureCredentialOptions
{
SharedTokenCacheTenantId = tenantId,
VisualStudioTenantId = tenantId,
VisualStudioCodeTenantId = tenantId,
ExcludeManagedIdentityCredential = environmentOptions.EnvironmentType == EnvironmentType.Local,
ExcludeAzurePowerShellCredential = true,
ExcludeInteractiveBrowserCredential = true,
ExcludeSharedTokenCacheCredential = true,
ExcludeEnvironmentCredential = true,
};
}
12 changes: 12 additions & 0 deletions src/Atc.Azure.Options/Providers/IAzureCredentialOptionsProvider.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace Atc.Azure.Options.Providers;

public interface IAzureCredentialOptionsProvider
{
DefaultAzureCredentialOptions GetAzureCredentialOptions(
EnvironmentOptions environmentOptions,
ClientAuthorizationOptions authorizationOptions);

DefaultAzureCredentialOptions GetAzureCredentialOptions(
EnvironmentOptions environmentOptions,
string tenantId);
}

0 comments on commit ed9b1f9

Please sign in to comment.