Skip to content

Commit

Permalink
Fix config validation
Browse files Browse the repository at this point in the history
  • Loading branch information
mtibben committed Mar 1, 2023
1 parent 624fb04 commit 1ca5051
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions vault/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,10 @@ func (c *Config) HasRole() bool {
return c.RoleARN != ""
}

func (c *Config) HasSSOSession() bool {
return c.SSOSession != ""
}

func (c *Config) HasSSOStartURL() bool {
return c.SSOStartURL != ""
}
Expand Down Expand Up @@ -707,6 +711,10 @@ func (c *Config) GetSessionTokenDuration() time.Duration {
}

func (c *Config) Validate() error {
if c.HasSSOSession() && !c.HasSSOStartURL() {
return fmt.Errorf("profile '%s' has sso_session but no sso_start_url", c.ProfileName)
}

n := 0
if c.HasSSOStartURL() {
n++
Expand All @@ -720,6 +728,9 @@ func (c *Config) Validate() error {
if c.HasRole() {
n++
}
if c.HasSourceProfile() {
n++
}

if n > 1 {
return fmt.Errorf("profile '%s' has more than one source of credentials", c.ProfileName)
Expand Down

0 comments on commit 1ca5051

Please sign in to comment.