Skip to content

Commit

Permalink
Added managed-identity credential type.
Browse files Browse the repository at this point in the history
  • Loading branch information
dlemstra committed Jun 25, 2024
1 parent d39a554 commit b191db6
Show file tree
Hide file tree
Showing 18 changed files with 246 additions and 8 deletions.
23 changes: 20 additions & 3 deletions src/Sign.Cli/AzureCredentialOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@ internal sealed class AzureCredentialOptions
{
internal Option<string?> CredentialTypeOption { get; } = new Option<string?>(["--azure-credential-type", "-act"], Resources.CredentialTypeOptionDescription).FromAmong(
AzureCredentialType.AzureCli,
AzureCredentialType.Environment);
AzureCredentialType.Environment,
AzureCredentialType.ManagedIdentity);
internal Option<string?> TenantIdOption { get; } = new(["--azure-tenant-id", "-ati"], Resources.TenantIdOptionDescription);
internal Option<string?> ManagedIdentityClientIdOption = new(["--managed-identity-client-id", "-mici"], Resources.ManagedIdentityClientIdOptionDescription);
internal Option<string?> ManagedIdentityResourceIdOption = new(["--managed-identity-resource-id", "-miri"], Resources.ManagedIdentityResourceIdOptionDescription);
internal Option<bool?> ObsoleteManagedIdentityOption { get; } = new(["--azure-key-vault-managed-identity", "-kvm"], Resources.ManagedIdentityOptionDescription) { IsHidden = true };
internal Option<string?> ObsoleteTenantIdOption { get; } = new(["--azure-key-vault-tenant-id", "-kvt"], Resources.TenantIdOptionDescription) { IsHidden = true };
internal Option<string?> ObsoleteClientIdOption { get; } = new(["--azure-key-vault-client-id", "-kvi"], Resources.ClientIdOptionDescription) { IsHidden = true };
Expand All @@ -26,6 +29,8 @@ internal void AddOptionsToCommand(Command command)
{
command.AddOption(CredentialTypeOption);
command.AddOption(TenantIdOption);
command.AddOption(ManagedIdentityClientIdOption);
command.AddOption(ManagedIdentityResourceIdOption);
command.AddOption(ObsoleteManagedIdentityOption);
command.AddOption(ObsoleteTenantIdOption);
command.AddOption(ObsoleteClientIdOption);
Expand All @@ -40,7 +45,19 @@ internal DefaultAzureCredentialOptions CreateDefaultAzureCredentialOptions(Parse
if (tenantId is not null)
{
options.TenantId = tenantId;
};
}

string? managedIdentityClientId = parseResult.GetValueForOption(ManagedIdentityClientIdOption);
if (managedIdentityClientId is not null)
{
options.ManagedIdentityClientId = managedIdentityClientId;
}

string? managedIdentityResourceId = parseResult.GetValueForOption(ManagedIdentityResourceIdOption);
if (managedIdentityResourceId is not null)
{
options.ManagedIdentityResourceId = new ResourceIdentifier(managedIdentityResourceId);
}

string? credentialType = parseResult.GetValueForOption(CredentialTypeOption);
if (credentialType is not null)
Expand All @@ -49,7 +66,7 @@ internal DefaultAzureCredentialOptions CreateDefaultAzureCredentialOptions(Parse
options.ExcludeAzureDeveloperCliCredential = true;
options.ExcludeAzurePowerShellCredential = true;
options.ExcludeEnvironmentCredential = credentialType != AzureCredentialType.Environment;
options.ExcludeManagedIdentityCredential = true;
options.ExcludeManagedIdentityCredential = credentialType != AzureCredentialType.ManagedIdentity;
options.ExcludeVisualStudioCredential = true;
options.ExcludeWorkloadIdentityCredential = true;
}
Expand Down
1 change: 1 addition & 0 deletions src/Sign.Cli/AzureCredentialType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ internal static class AzureCredentialType
{
public const string AzureCli = "azure-cli";
public const string Environment = "environment";
public const string ManagedIdentity = "managed-identity";
}
}
18 changes: 18 additions & 0 deletions src/Sign.Cli/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions src/Sign.Cli/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -180,12 +180,18 @@
<value>Invalid value for {0}. The value must be an absolute HTTP or HTTPS URL.</value>
<comment>{NumberedPlaceholder="{0}"} is an option name (e.g.: --timestamp-url) and should not be localized.</comment>
</data>
<data name="ManagedIdentityClientIdOptionDescription" xml:space="preserve">
<value>The client id of a user assigned ManagedIdentity.</value>
</data>
<data name="ManagedIdentityOptionDescription" xml:space="preserve">
<value>Managed identity to authenticate to Azure Key. (obsolete)</value>
</data>
<data name="ManagedIdentityOptionObsolete" xml:space="preserve">
<value>The -kvm and --azure-key-vault-managed-identity options are obsolete and should no longer be specified.</value>
</data>
<data name="ManagedIdentityResourceIdOptionDescription" xml:space="preserve">
<value>The resource id of a user assigned ManagedIdentity.</value>
</data>
<data name="MaxConcurrencyOptionDescription" xml:space="preserve">
<value>Maximum concurrency.</value>
</data>
Expand Down
10 changes: 10 additions & 0 deletions src/Sign.Cli/xlf/Resources.cs.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@
<target state="translated">Neplatná hodnota pro {0}. Hodnota musí být absolutní adresa URL protokolu HTTP nebo HTTPS.</target>
<note>{NumberedPlaceholder="{0}"} is an option name (e.g.: --timestamp-url) and should not be localized.</note>
</trans-unit>
<trans-unit id="ManagedIdentityClientIdOptionDescription">
<source>The client id of a user assigned ManagedIdentity.</source>
<target state="new">The client id of a user assigned ManagedIdentity.</target>
<note />
</trans-unit>
<trans-unit id="ManagedIdentityOptionDescription">
<source>Managed identity to authenticate to Azure Key. (obsolete)</source>
<target state="new">Managed identity to authenticate to Azure Key. (obsolete)</target>
Expand All @@ -107,6 +112,11 @@
<target state="new">The -kvm and --azure-key-vault-managed-identity options are obsolete and should no longer be specified.</target>
<note />
</trans-unit>
<trans-unit id="ManagedIdentityResourceIdOptionDescription">
<source>The resource id of a user assigned ManagedIdentity.</source>
<target state="new">The resource id of a user assigned ManagedIdentity.</target>
<note />
</trans-unit>
<trans-unit id="MaxConcurrencyOptionDescription">
<source>Maximum concurrency.</source>
<target state="translated">Maximální souběžnost.</target>
Expand Down
10 changes: 10 additions & 0 deletions src/Sign.Cli/xlf/Resources.de.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@
<target state="translated">Ungültiger Wert für {0}. Der Wert muss eine absolute HTTP- oder HTTPS-URL sein.</target>
<note>{NumberedPlaceholder="{0}"} is an option name (e.g.: --timestamp-url) and should not be localized.</note>
</trans-unit>
<trans-unit id="ManagedIdentityClientIdOptionDescription">
<source>The client id of a user assigned ManagedIdentity.</source>
<target state="new">The client id of a user assigned ManagedIdentity.</target>
<note />
</trans-unit>
<trans-unit id="ManagedIdentityOptionDescription">
<source>Managed identity to authenticate to Azure Key. (obsolete)</source>
<target state="translated">Verwaltete Identität für die Authentifizierung bei Azure Key. (veraltet)</target>
Expand All @@ -107,6 +112,11 @@
<target state="translated">Die Optionen „-kvm“ und „--azure-key-vault-managed-identity“ sind veraltet und sollten nicht mehr angegeben werden.</target>
<note />
</trans-unit>
<trans-unit id="ManagedIdentityResourceIdOptionDescription">
<source>The resource id of a user assigned ManagedIdentity.</source>
<target state="new">The resource id of a user assigned ManagedIdentity.</target>
<note />
</trans-unit>
<trans-unit id="MaxConcurrencyOptionDescription">
<source>Maximum concurrency.</source>
<target state="translated">Maximale Parallelität.</target>
Expand Down
10 changes: 10 additions & 0 deletions src/Sign.Cli/xlf/Resources.es.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@
<target state="translated">Valor no válido para {0}. El valor debe ser una dirección URL HTTP o HTTPS absoluta.</target>
<note>{NumberedPlaceholder="{0}"} is an option name (e.g.: --timestamp-url) and should not be localized.</note>
</trans-unit>
<trans-unit id="ManagedIdentityClientIdOptionDescription">
<source>The client id of a user assigned ManagedIdentity.</source>
<target state="new">The client id of a user assigned ManagedIdentity.</target>
<note />
</trans-unit>
<trans-unit id="ManagedIdentityOptionDescription">
<source>Managed identity to authenticate to Azure Key. (obsolete)</source>
<target state="translated">Identidad administrada para autenticarse en Azure Key. (obsoleto)</target>
Expand All @@ -107,6 +112,11 @@
<target state="translated">Las opciones -kvm y --azure-key-vault-managed-identity están obsoletas y ya no deben especificarse.</target>
<note />
</trans-unit>
<trans-unit id="ManagedIdentityResourceIdOptionDescription">
<source>The resource id of a user assigned ManagedIdentity.</source>
<target state="new">The resource id of a user assigned ManagedIdentity.</target>
<note />
</trans-unit>
<trans-unit id="MaxConcurrencyOptionDescription">
<source>Maximum concurrency.</source>
<target state="translated">Simultaneidad máxima.</target>
Expand Down
10 changes: 10 additions & 0 deletions src/Sign.Cli/xlf/Resources.fr.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@
<target state="translated">Valeur non valide pour {0}. La valeur doit être une URL HTTP ou HTTPS absolue.</target>
<note>{NumberedPlaceholder="{0}"} is an option name (e.g.: --timestamp-url) and should not be localized.</note>
</trans-unit>
<trans-unit id="ManagedIdentityClientIdOptionDescription">
<source>The client id of a user assigned ManagedIdentity.</source>
<target state="new">The client id of a user assigned ManagedIdentity.</target>
<note />
</trans-unit>
<trans-unit id="ManagedIdentityOptionDescription">
<source>Managed identity to authenticate to Azure Key. (obsolete)</source>
<target state="new">Managed identity to authenticate to Azure Key. (obsolete)</target>
Expand All @@ -107,6 +112,11 @@
<target state="new">The -kvm and --azure-key-vault-managed-identity options are obsolete and should no longer be specified.</target>
<note />
</trans-unit>
<trans-unit id="ManagedIdentityResourceIdOptionDescription">
<source>The resource id of a user assigned ManagedIdentity.</source>
<target state="new">The resource id of a user assigned ManagedIdentity.</target>
<note />
</trans-unit>
<trans-unit id="MaxConcurrencyOptionDescription">
<source>Maximum concurrency.</source>
<target state="translated">Concurrence maximale.</target>
Expand Down
10 changes: 10 additions & 0 deletions src/Sign.Cli/xlf/Resources.it.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@
<target state="translated">Valore non valido per {0}. Il valore deve essere un URL HTTP o HTTPS assoluto.</target>
<note>{NumberedPlaceholder="{0}"} is an option name (e.g.: --timestamp-url) and should not be localized.</note>
</trans-unit>
<trans-unit id="ManagedIdentityClientIdOptionDescription">
<source>The client id of a user assigned ManagedIdentity.</source>
<target state="new">The client id of a user assigned ManagedIdentity.</target>
<note />
</trans-unit>
<trans-unit id="ManagedIdentityOptionDescription">
<source>Managed identity to authenticate to Azure Key. (obsolete)</source>
<target state="new">Managed identity to authenticate to Azure Key. (obsolete)</target>
Expand All @@ -107,6 +112,11 @@
<target state="new">The -kvm and --azure-key-vault-managed-identity options are obsolete and should no longer be specified.</target>
<note />
</trans-unit>
<trans-unit id="ManagedIdentityResourceIdOptionDescription">
<source>The resource id of a user assigned ManagedIdentity.</source>
<target state="new">The resource id of a user assigned ManagedIdentity.</target>
<note />
</trans-unit>
<trans-unit id="MaxConcurrencyOptionDescription">
<source>Maximum concurrency.</source>
<target state="translated">Concorrenza massima.</target>
Expand Down
10 changes: 10 additions & 0 deletions src/Sign.Cli/xlf/Resources.ja.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@
<target state="translated">{0}の値が無効です。値は HTTP または HTTPS の絶対 URL である必要があります。</target>
<note>{NumberedPlaceholder="{0}"} is an option name (e.g.: --timestamp-url) and should not be localized.</note>
</trans-unit>
<trans-unit id="ManagedIdentityClientIdOptionDescription">
<source>The client id of a user assigned ManagedIdentity.</source>
<target state="new">The client id of a user assigned ManagedIdentity.</target>
<note />
</trans-unit>
<trans-unit id="ManagedIdentityOptionDescription">
<source>Managed identity to authenticate to Azure Key. (obsolete)</source>
<target state="new">Managed identity to authenticate to Azure Key. (obsolete)</target>
Expand All @@ -107,6 +112,11 @@
<target state="new">The -kvm and --azure-key-vault-managed-identity options are obsolete and should no longer be specified.</target>
<note />
</trans-unit>
<trans-unit id="ManagedIdentityResourceIdOptionDescription">
<source>The resource id of a user assigned ManagedIdentity.</source>
<target state="new">The resource id of a user assigned ManagedIdentity.</target>
<note />
</trans-unit>
<trans-unit id="MaxConcurrencyOptionDescription">
<source>Maximum concurrency.</source>
<target state="translated">最大コンカレンシー。</target>
Expand Down
10 changes: 10 additions & 0 deletions src/Sign.Cli/xlf/Resources.ko.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@
<target state="translated">{0}에 대한 값이 잘못되었습니다. 값은 절대 HTTP 또는 HTTPS URL이어야 합니다.</target>
<note>{NumberedPlaceholder="{0}"} is an option name (e.g.: --timestamp-url) and should not be localized.</note>
</trans-unit>
<trans-unit id="ManagedIdentityClientIdOptionDescription">
<source>The client id of a user assigned ManagedIdentity.</source>
<target state="new">The client id of a user assigned ManagedIdentity.</target>
<note />
</trans-unit>
<trans-unit id="ManagedIdentityOptionDescription">
<source>Managed identity to authenticate to Azure Key. (obsolete)</source>
<target state="translated">Azure Key에 인증할 관리 ID입니다. (사용되지 않음)</target>
Expand All @@ -107,6 +112,11 @@
<target state="translated">-kvm 및 --azure-key-vault-managed-identity 옵션은 사용되지 않으므로 더 이상 지정하지 않아야 합니다.</target>
<note />
</trans-unit>
<trans-unit id="ManagedIdentityResourceIdOptionDescription">
<source>The resource id of a user assigned ManagedIdentity.</source>
<target state="new">The resource id of a user assigned ManagedIdentity.</target>
<note />
</trans-unit>
<trans-unit id="MaxConcurrencyOptionDescription">
<source>Maximum concurrency.</source>
<target state="translated">최대 동시성입니다.</target>
Expand Down
10 changes: 10 additions & 0 deletions src/Sign.Cli/xlf/Resources.pl.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@
<target state="translated">Nieprawidłowa wartość dla {0}. Wartość musi być bezwzględnym adresem URL protokołu HTTP lub HTTPS.</target>
<note>{NumberedPlaceholder="{0}"} is an option name (e.g.: --timestamp-url) and should not be localized.</note>
</trans-unit>
<trans-unit id="ManagedIdentityClientIdOptionDescription">
<source>The client id of a user assigned ManagedIdentity.</source>
<target state="new">The client id of a user assigned ManagedIdentity.</target>
<note />
</trans-unit>
<trans-unit id="ManagedIdentityOptionDescription">
<source>Managed identity to authenticate to Azure Key. (obsolete)</source>
<target state="new">Managed identity to authenticate to Azure Key. (obsolete)</target>
Expand All @@ -107,6 +112,11 @@
<target state="new">The -kvm and --azure-key-vault-managed-identity options are obsolete and should no longer be specified.</target>
<note />
</trans-unit>
<trans-unit id="ManagedIdentityResourceIdOptionDescription">
<source>The resource id of a user assigned ManagedIdentity.</source>
<target state="new">The resource id of a user assigned ManagedIdentity.</target>
<note />
</trans-unit>
<trans-unit id="MaxConcurrencyOptionDescription">
<source>Maximum concurrency.</source>
<target state="translated">Maksymalna współbieżność.</target>
Expand Down
10 changes: 10 additions & 0 deletions src/Sign.Cli/xlf/Resources.pt-BR.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@
<target state="translated">Valor inválido para {0}. O valor deve ser uma URL HTTP ou HTTPS absoluta.</target>
<note>{NumberedPlaceholder="{0}"} is an option name (e.g.: --timestamp-url) and should not be localized.</note>
</trans-unit>
<trans-unit id="ManagedIdentityClientIdOptionDescription">
<source>The client id of a user assigned ManagedIdentity.</source>
<target state="new">The client id of a user assigned ManagedIdentity.</target>
<note />
</trans-unit>
<trans-unit id="ManagedIdentityOptionDescription">
<source>Managed identity to authenticate to Azure Key. (obsolete)</source>
<target state="new">Managed identity to authenticate to Azure Key. (obsolete)</target>
Expand All @@ -107,6 +112,11 @@
<target state="new">The -kvm and --azure-key-vault-managed-identity options are obsolete and should no longer be specified.</target>
<note />
</trans-unit>
<trans-unit id="ManagedIdentityResourceIdOptionDescription">
<source>The resource id of a user assigned ManagedIdentity.</source>
<target state="new">The resource id of a user assigned ManagedIdentity.</target>
<note />
</trans-unit>
<trans-unit id="MaxConcurrencyOptionDescription">
<source>Maximum concurrency.</source>
<target state="translated">Simultaneidade máxima.</target>
Expand Down
Loading

0 comments on commit b191db6

Please sign in to comment.