Skip to content

Commit

Permalink
Remove federated:id from scopes before passing it on
Browse files Browse the repository at this point in the history
  • Loading branch information
loafoe committed Jul 8, 2024
1 parent 6a05098 commit 4751cae
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion connector/hsdp/hsdp.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ func (c *Config) Open(id string, logger *slog.Logger) (conn connector.Connector,

scopes := []string{oidc.ScopeOpenID}
if len(c.Scopes) > 0 {
scopes = append(scopes, c.Scopes...)
filtered := removeElement(c.Scopes, "federated:id") // HSP IAM does not support scopes with colon
scopes = append(scopes, filtered...)
} else {
scopes = append(scopes, "profile", "email", "groups")
}
Expand Down Expand Up @@ -434,3 +435,14 @@ func (c *HSDPConnector) createIdentity(ctx context.Context, identity connector.I

return identity, nil
}

// removeElement removes an element from a slice. It works for any ordered type (e.g., numbers, strings).
func removeElement[T comparable](slice []T, elementToRemove T) []T {
var newSlice []T
for _, item := range slice {
if item != elementToRemove {
newSlice = append(newSlice, item)
}
}
return newSlice
}

0 comments on commit 4751cae

Please sign in to comment.