Skip to content

Commit

Permalink
make client_scopes optional
Browse files Browse the repository at this point in the history
  • Loading branch information
sei-aschlackman committed Oct 15, 2024
1 parent 816f65e commit 5df0155
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 5 additions & 2 deletions internal/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,12 @@ func Provider() *schema.Provider {
Elem: &schema.Schema{
Type: schema.TypeString,
},
Required: true,
Optional: true,
DefaultFunc: func() (interface{}, error) {
return os.Getenv("SEI_CRUCIBLE_CLIENT_SCOPES"), nil
if val := os.Getenv("SEI_CRUCIBLE_CLIENT_SCOPES"); val != "" {
return val, nil
}
return []interface{}{}, nil // Return an empty list if the environment variable is not set
},
},
},
Expand Down
4 changes: 4 additions & 0 deletions internal/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ func ToStringSlice(data *[]interface{}) *[]string {
func GetAuth(m map[string]string) (string, error) {
scopes := strings.Split(m["client_scopes"], ",")

if len(scopes) == 0 || (len(scopes) == 1 && scopes[0] == "") {
scopes = nil
}

con := &oauth2.Config{
ClientID: m["client_id"],
ClientSecret: m["client_secret"],
Expand Down

0 comments on commit 5df0155

Please sign in to comment.