Skip to content

Commit

Permalink
Merge pull request #122 from okta/prep_v1_2_1
Browse files Browse the repository at this point in the history
Refine friendly IdP and Role label
  • Loading branch information
MikeMondragon-okta authored Aug 15, 2023
2 parents e199e6a + 4f8154b commit 7e7bb0c
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 14 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 1.2.1 (August 15, 2023)

* Friendly IdP and Role labels don't also print out ARN value (less text clutter in the UI)

## 1.2.0 (August 15, 2023)

* [Friendly Role menu labels](https://github.com/okta/okta-aws-cli#friendly-idp-and-role-menu-labels) for long ARN values can be set in `$HOME/.okta/okta.yaml`
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -314,14 +314,14 @@ that practice with read-only friendly okta-aws-cli application values.

```
? Choose an IdP: [Use arrows to move, type to filter]
> Fed App 1 Label (arn:aws:iam::123456789012:saml-provider/company-okta-idp)
Fed App 2 Label (arn:aws:iam::012345678901:saml-provider/company-okta-idp)
Fed App 3 Label (arn:aws:iam::901234567890:saml-provider/company-okta-idp)
Fed App 4 Label (arn:aws:iam::890123456789:saml-provider/company-okta-idp)
> Fed App 1 Label
Fed App 2 Label
Fed App 3 Label
Fed App 4 Label
? Choose a Role: [Use arrows to move, type to filter]
> Admin (arn:aws:iam::123456789012:role/admin)
Op (arn:aws:iam::123456789012:role/operator)
Ops
```

#### Example `$HOME/.okta/okta.yaml`
Expand Down Expand Up @@ -351,8 +351,8 @@ awscli:
Marketing Development

? Choose a Role: [Use arrows to move, type to filter]
> Prod Admin (arn:aws:iam::123456789012:role/admin)
Prod Ops (arn:aws:iam::123456789012:role/operator)
> Prod Admin
Prod Ops
```

#### Debug okta.yaml
Expand Down
2 changes: 1 addition & 1 deletion internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (

const (
// Version app version
Version = "1.2.0"
Version = "1.2.1"

// AWSCredentialsFormat format const
AWSCredentialsFormat = "aws-credentials"
Expand Down
9 changes: 3 additions & 6 deletions internal/sessiontoken/sessiontoken.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ const (
roleSelectedTemplate = ` {{color "default+hb"}}Role: {{color "reset"}}{{color "cyan"}}{{ .Role }}{{color "reset"}}`
dotOktaDir = ".okta"
tokenFileName = "awscli-access-token.json"

choiceArnPrintFmt = "%s (%s)"
)

type idpTemplateData struct {
Expand Down Expand Up @@ -234,7 +232,7 @@ func (s *SessionToken) choiceFriendlyLabelIDP(alternative string, oktaConfig *co
if s.config.Debug() {
fmt.Fprintf(os.Stderr, " found IdP ARN %q having friendly label %q\n", arn, label)
}
return fmt.Sprintf(choiceArnPrintFmt, label, arn)
return label
} else if s.config.Debug() {
fmt.Fprintf(os.Stderr, " did not find friendly label for IdP ARN\n")
fmt.Fprintf(os.Stderr, " %q\n", arn)
Expand All @@ -253,8 +251,7 @@ func (s *SessionToken) selectFedApp(apps []*oktaApplication) (string, error) {
oktaConfig, _ := s.config.OktaConfig()

for i, app := range apps {
defaultLabel := fmt.Sprintf(choiceArnPrintFmt, app.Label, app.Settings.App.IdentityProviderARN)
choiceLabel := s.choiceFriendlyLabelIDP(defaultLabel, oktaConfig, app.Settings.App.IdentityProviderARN)
choiceLabel := s.choiceFriendlyLabelIDP(app.Label, oktaConfig, app.Settings.App.IdentityProviderARN)

// when OKTA_AWSCLI_IAM_IDP / --aws-iam-idp is set
if s.config.AWSIAMIdP() == app.Settings.App.IdentityProviderARN {
Expand Down Expand Up @@ -378,7 +375,7 @@ func (s *SessionToken) choiceFriendlyLabelRole(arn string, oktaConfig *config.Ok
if s.config.Debug() {
fmt.Fprintf(os.Stderr, " found Role ARN %q having friendly label %q\n", arn, label)
}
return fmt.Sprintf(choiceArnPrintFmt, label, arn)
return label
} else if s.config.Debug() {
fmt.Fprintf(os.Stderr, " did not find friendly label for Role ARN\n")
fmt.Fprintf(os.Stderr, " %q\n", arn)
Expand Down

0 comments on commit 7e7bb0c

Please sign in to comment.