Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 3 additions & 3 deletions lib/auth/clt.go
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ type IdentityService interface {
UpsertOIDCConnector(ctx context.Context, connector types.OIDCConnector) error
// GetOIDCConnector returns OIDC connector information by id
GetOIDCConnector(ctx context.Context, id string, withSecrets bool) (types.OIDCConnector, error)
// GetOIDCConnectors gets OIDC connectors list
// GetOIDCConnectors gets valid OIDC connectors list
GetOIDCConnectors(ctx context.Context, withSecrets bool) ([]types.OIDCConnector, error)
// DeleteOIDCConnector deletes OIDC connector by ID
DeleteOIDCConnector(ctx context.Context, connectorID string) error
Expand All @@ -428,7 +428,7 @@ type IdentityService interface {
UpsertSAMLConnector(ctx context.Context, connector types.SAMLConnector) error
// GetSAMLConnector returns SAML connector information by id
GetSAMLConnector(ctx context.Context, id string, withSecrets bool) (types.SAMLConnector, error)
// GetSAMLConnectors gets SAML connectors list
// GetSAMLConnectors gets valid SAML connectors list
GetSAMLConnectors(ctx context.Context, withSecrets bool) ([]types.SAMLConnector, error)
// DeleteSAMLConnector deletes SAML connector by ID
DeleteSAMLConnector(ctx context.Context, connectorID string) error
Expand All @@ -441,7 +441,7 @@ type IdentityService interface {

// UpsertGithubConnector creates or updates a Github connector
UpsertGithubConnector(ctx context.Context, connector types.GithubConnector) error
// GetGithubConnectors returns all configured Github connectors
// GetGithubConnectors returns valid Github connectors
GetGithubConnectors(ctx context.Context, withSecrets bool) ([]types.GithubConnector, error)
// GetGithubConnector returns the specified Github connector
GetGithubConnector(ctx context.Context, id string, withSecrets bool) (types.GithubConnector, error)
Expand Down
6 changes: 3 additions & 3 deletions lib/auth/grpcserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -2843,7 +2843,7 @@ func (g *GRPCServer) GetOIDCConnector(ctx context.Context, req *types.ResourceWi
return connector, nil
}

// GetOIDCConnectors retrieves all OIDC connectors.
// GetOIDCConnectors retrieves valid OIDC connectors, errors from individual connectors are not forwarded.
func (g *GRPCServer) GetOIDCConnectors(ctx context.Context, req *types.ResourcesWithSecretsRequest) (*types.OIDCConnectorV3List, error) {
auth, err := g.authenticate(ctx)
if err != nil {
Expand Down Expand Up @@ -2932,7 +2932,7 @@ func (g *GRPCServer) GetSAMLConnector(ctx context.Context, req *types.ResourceWi
return samlConnectorV2, nil
}

// GetSAMLConnectors retrieves all SAML connectors.
// GetSAMLConnectors retrieves valid SAML connectors, errors from individual connectors are not forwarded.
func (g *GRPCServer) GetSAMLConnectors(ctx context.Context, req *types.ResourcesWithSecretsRequest) (*types.SAMLConnectorV2List, error) {
auth, err := g.authenticate(ctx)
if err != nil {
Expand Down Expand Up @@ -3021,7 +3021,7 @@ func (g *GRPCServer) GetGithubConnector(ctx context.Context, req *types.Resource
return githubConnectorV3, nil
}

// GetGithubConnectors retrieves all Github connectors.
// GetGithubConnectors retrieves valid GitHub connectors, errors from individual connectors are not forwarded.
func (g *GRPCServer) GetGithubConnectors(ctx context.Context, req *types.ResourcesWithSecretsRequest) (*types.GithubConnectorV3List, error) {
auth, err := g.authenticate(ctx)
if err != nil {
Expand Down
8 changes: 5 additions & 3 deletions lib/services/identity.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,8 @@ type Identity interface {
// GetOIDCConnector returns OIDC connector data, withSecrets adds or removes client secret from return results
GetOIDCConnector(ctx context.Context, id string, withSecrets bool) (types.OIDCConnector, error)

// GetOIDCConnectors returns registered connectors, withSecrets adds or removes client secret from return results
// GetOIDCConnectors returns valid registered connectors, withSecrets adds or removes client secret from return
// results. Invalid Connectors are simply logged but errors are not forwarded.
GetOIDCConnectors(ctx context.Context, withSecrets bool) ([]types.OIDCConnector, error)

// CreateOIDCAuthRequest creates new auth request
Expand All @@ -190,7 +191,8 @@ type Identity interface {
// GetSAMLConnector returns OIDC connector data, withSecrets adds or removes secrets from return results
GetSAMLConnector(ctx context.Context, id string, withSecrets bool) (types.SAMLConnector, error)

// GetSAMLConnectors returns registered connectors, withSecrets adds or removes secret from return results
// GetSAMLConnectors returns valid registered connectors, withSecrets adds or removes secret from return results.
// Invalid Connectors are simply logged but errors are not forwarded.
GetSAMLConnectors(ctx context.Context, withSecrets bool) ([]types.SAMLConnector, error)

// CreateSAMLAuthRequest creates new auth request
Expand All @@ -208,7 +210,7 @@ type Identity interface {
// UpsertGithubConnector creates or updates a new Github connector
UpsertGithubConnector(ctx context.Context, connector types.GithubConnector) error

// GetGithubConnectors returns all configured Github connectors
// GetGithubConnectors returns valid Github connectors, invalid Connectors are simply logged but errors are not forwarded.
GetGithubConnectors(ctx context.Context, withSecrets bool) ([]types.GithubConnector, error)

// GetGithubConnector returns a Github connector by its name
Expand Down
36 changes: 24 additions & 12 deletions lib/services/local/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -1017,18 +1017,22 @@ func (s *IdentityService) GetOIDCConnectors(ctx context.Context, withSecrets boo
if err != nil {
return nil, trace.Wrap(err)
}
connectors := make([]types.OIDCConnector, len(result.Items))
for i, item := range result.Items {
var connectors []types.OIDCConnector
for _, item := range result.Items {
conn, err := services.UnmarshalOIDCConnector(
item.Value, services.WithExpires(item.Expires))
if err != nil {
return nil, trace.Wrap(err)
logrus.
WithError(err).
WithField("key", item.Key).
Errorf("Error unmarshaling OIDC Connector")
continue
}
if !withSecrets {
conn.SetClientSecret("")
conn.SetGoogleServiceAccount("")
}
connectors[i] = conn
connectors = append(connectors, conn)
}
return connectors, nil
}
Expand Down Expand Up @@ -1135,12 +1139,16 @@ func (s *IdentityService) GetSAMLConnectors(ctx context.Context, withSecrets boo
if err != nil {
return nil, trace.Wrap(err)
}
connectors := make([]types.SAMLConnector, len(result.Items))
for i, item := range result.Items {
var connectors []types.SAMLConnector
for _, item := range result.Items {
conn, err := services.UnmarshalSAMLConnector(
item.Value, services.WithExpires(item.Expires))
if err != nil {
return nil, trace.Wrap(err)
logrus.
WithError(err).
WithField("key", item.Key).
Errorf("Error unmarshaling SAML Connector")
continue
}
if !withSecrets {
keyPair := conn.GetSigningKeyPair()
Expand All @@ -1149,7 +1157,7 @@ func (s *IdentityService) GetSAMLConnectors(ctx context.Context, withSecrets boo
conn.SetSigningKeyPair(keyPair)
}
}
connectors[i] = conn
connectors = append(connectors, conn)
}
return connectors, nil
}
Expand Down Expand Up @@ -1275,16 +1283,20 @@ func (s *IdentityService) GetGithubConnectors(ctx context.Context, withSecrets b
if err != nil {
return nil, trace.Wrap(err)
}
connectors := make([]types.GithubConnector, len(result.Items))
for i, item := range result.Items {
var connectors []types.GithubConnector
for _, item := range result.Items {
connector, err := services.UnmarshalGithubConnector(item.Value)
if err != nil {
return nil, trace.Wrap(err)
logrus.
WithError(err).
WithField("key", item.Key).
Errorf("Error unmarshaling GitHub Connector")
continue
}
if !withSecrets {
connector.SetClientSecret("")
}
connectors[i] = connector
connectors = append(connectors, connector)
}
return connectors, nil
}
Expand Down