-
Notifications
You must be signed in to change notification settings - Fork 91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added support for Trusted Signing #716
Merged
Merged
Changes from 12 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
2cba442
Added Sign.SignatureProviders.TrustedSigning.
dlemstra 5a5b580
Added unit tests for Sign.SignatureProviders.TrustedSigning.
dlemstra acab2e2
Added TrustedSigningCommand.
dlemstra 55ebde3
No longer put the CodeCommand in a private field.
dlemstra d1512cb
Moved the Azure auth options to a separate class and share this betwe…
dlemstra 66669a2
Improved translations.
dlemstra bf64312
Changes due to review comments.
dlemstra 3ddb680
Use a different short option name for the --trusted-signing-certifica…
dlemstra c785523
Inject the logger in the constructor of the TrustedSigningService ins…
dlemstra 3a5db7e
Use certificate instead of public key in the naming and dded comment …
dlemstra 9e930d0
Create separate resource file for the Sign.SignatureProviders.Trusted…
dlemstra ce905d0
Updated comment to make it more clear why the reference was added.
dlemstra 57ad13a
Renamed the class that contains the options for the credentials and d…
dlemstra File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE.txt file in the project root for more information. | ||
|
||
using System.CommandLine; | ||
using System.CommandLine.Invocation; | ||
using Azure.Core; | ||
using Azure.Identity; | ||
using Sign.Core; | ||
|
||
namespace Sign.Cli | ||
{ | ||
internal sealed class AzureAuthOptions | ||
{ | ||
internal Option<bool> ManagedIdentityOption { get; } = new(["-azm", "--azure-managed-identity"], getDefaultValue: () => false, Resources.ManagedIdentityOptionDescription); | ||
internal Option<string?> TenantIdOption { get; } = new(["-azt", "--azure-tenant-id"], Resources.TenantIdOptionDescription); | ||
internal Option<string?> ClientIdOption { get; } = new(["-azi", "--azure-client-id"], Resources.ClientIdOptionDescription); | ||
internal Option<string?> ClientSecretOption { get; } = new(["-azs", "--azure-client-secret"], Resources.ClientSecretOptionDescription); | ||
joelverhagen marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
internal void AddOptionsToCommand(Command command) | ||
{ | ||
command.AddOption(ManagedIdentityOption); | ||
command.AddOption(TenantIdOption); | ||
command.AddOption(ClientIdOption); | ||
command.AddOption(ClientSecretOption); | ||
} | ||
|
||
internal TokenCredential? CreateTokenCredential(InvocationContext context) | ||
{ | ||
bool useManagedIdentity = context.ParseResult.GetValueForOption(ManagedIdentityOption); | ||
|
||
if (useManagedIdentity) | ||
{ | ||
return new DefaultAzureCredential(); | ||
joelverhagen marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
string? tenantId = context.ParseResult.GetValueForOption(TenantIdOption); | ||
string? clientId = context.ParseResult.GetValueForOption(ClientIdOption); | ||
string? secret = context.ParseResult.GetValueForOption(ClientSecretOption); | ||
|
||
if (string.IsNullOrEmpty(tenantId) || | ||
string.IsNullOrEmpty(clientId) || | ||
string.IsNullOrEmpty(secret)) | ||
{ | ||
context.Console.Error.WriteFormattedLine( | ||
Resources.InvalidClientSecretCredential, | ||
TenantIdOption, | ||
ClientIdOption, | ||
ClientSecretOption); | ||
context.ExitCode = ExitCode.NoInputsFound; | ||
return null; | ||
} | ||
|
||
return new ClientSecretCredential(tenantId, clientId, secret); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think some of these descriptions mention Key Vault but these don't make sense when the options are used in the
TrustedSigningCommand
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for finding that. I will update the documentation once it is clear that this new
AzureAuthOptions
class is a move in the right direction.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have updated the documentation.