Skip to content
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

Add support for custom role session name #78

Merged
merged 7 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions aws_signing_helper/credentials.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ type CredentialsOpts struct {
Version string
LibPkcs11 string
ReusePin bool
RoleSessionName string
}

// Function to create session and generate credentials
Expand Down Expand Up @@ -107,6 +108,9 @@ func GenerateCredentials(opts *CredentialsOpts, signer Signer, signatureAlgorith
RoleArn: &opts.RoleArn,
SessionName: nil,
}
if opts.RoleSessionName != "" {
createSessionRequest.RoleSessionName = &opts.RoleSessionName
}
output, err := rolesAnywhereClient.CreateSession(&createSessionRequest)
if err != nil {
return CredentialProcessOutput{}, err
Expand Down
3 changes: 3 additions & 0 deletions cmd/credentials.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ var (
withProxy bool
debug bool
reusePin bool
roleSessionName string

certificateId string
privateKeyId string
Expand Down Expand Up @@ -72,6 +73,7 @@ func initCredentialsSubCommand(subCmd *cobra.Command) {
subCmd.PersistentFlags().BoolVar(&reusePin, "reuse-pin", false, "Use the CKU_USER PIN as the CKU_CONTEXT_SPECIFIC PIN for "+
"private key objects, when they are first used to sign. If the CKU_USER PIN doesn't work as the CKU_CONTEXT_SPECIFIC PIN "+
"for a given private key object, fall back to prompting the user")
subCmd.PersistentFlags().StringVar(&roleSessionName, "role-session-name", "", "An identifier of a role session")

subCmd.MarkFlagsMutuallyExclusive("certificate", "cert-selector")
subCmd.MarkFlagsMutuallyExclusive("certificate", "system-store-name")
Expand Down Expand Up @@ -242,6 +244,7 @@ func PopulateCredentialsOptions() error {
Version: Version,
LibPkcs11: libPkcs11,
ReusePin: reusePin,
RoleSessionName: roleSessionName,
}

return nil
Expand Down
12 changes: 12 additions & 0 deletions rolesanywhere/api.go

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

Loading