Skip to content
Open
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
16 changes: 10 additions & 6 deletions cmd/dex/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,9 +365,10 @@ func (s *Storage) UnmarshalJSON(b []byte) error {
// Connector is a magical type that can unmarshal YAML dynamically. The
// Type field determines the connector type, which is then customized for Config.
type Connector struct {
Type string `json:"type"`
Name string `json:"name"`
ID string `json:"id"`
Type string `json:"type"`
Name string `json:"name"`
ID string `json:"id"`
Hidden bool `json:"hidden"`

Config server.ConnectorConfig `json:"config"`
}
Expand All @@ -376,9 +377,10 @@ type Connector struct {
// dynamically determine the type of the connector config.
func (c *Connector) UnmarshalJSON(b []byte) error {
var conn struct {
Type string `json:"type"`
Name string `json:"name"`
ID string `json:"id"`
Type string `json:"type"`
Name string `json:"name"`
ID string `json:"id"`
Hidden bool `json:"hidden"`

Config json.RawMessage `json:"config"`
}
Expand Down Expand Up @@ -422,6 +424,7 @@ func (c *Connector) UnmarshalJSON(b []byte) error {
Name: conn.Name,
ID: conn.ID,
Config: connConfig,
Hidden: conn.Hidden,
}
return nil
}
Expand All @@ -438,6 +441,7 @@ func ToStorageConnector(c Connector) (storage.Connector, error) {
Type: c.Type,
Name: c.Name,
Config: data,
Hidden: c.Hidden,
}, nil
}

Expand Down
9 changes: 5 additions & 4 deletions server/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,11 @@ func (s *Server) handleAuthorization(w http.ResponseWriter, r *http.Request) {
for index, conn := range connectors {
connURL.Path = s.absPath("/auth", url.PathEscape(conn.ID))
connectorInfos[index] = connectorInfo{
ID: conn.ID,
Name: conn.Name,
Type: conn.Type,
URL: template.URL(connURL.String()),
ID: conn.ID,
Name: conn.Name,
Type: conn.Type,
URL: template.URL(connURL.String()),
Hidden: conn.Hidden,
}
}

Expand Down
19 changes: 13 additions & 6 deletions server/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,10 +249,11 @@ var scopeDescriptions = map[string]string{
}

type connectorInfo struct {
ID string
Name string
URL template.URL
Type string
ID string
Name string
URL template.URL
Type string
Hidden bool
}

type byName []connectorInfo
Expand Down Expand Up @@ -283,11 +284,17 @@ func (t *templates) deviceSuccess(r *http.Request, w http.ResponseWriter, client
}

func (t *templates) login(r *http.Request, w http.ResponseWriter, connectors []connectorInfo) error {
sort.Sort(byName(connectors))
var visibleConnectors []connectorInfo
for _, connector := range connectors {
if !connector.Hidden {
visibleConnectors = append(visibleConnectors, connector)
}
}
sort.Sort(byName(visibleConnectors))
data := struct {
Connectors []connectorInfo
ReqPath string
}{connectors, r.URL.Path}
}{visibleConnectors, r.URL.Path}
return renderTemplate(w, t.loginTmpl, data)
}

Expand Down
2 changes: 2 additions & 0 deletions storage/conformance/conformance.go
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,7 @@ func testConnectorCRUD(t *testing.T, s storage.Storage) {
Type: "Default",
Name: "Default",
Config: config1,
Hidden: false,
}

if err := s.CreateConnector(ctx, c1); err != nil {
Expand All @@ -639,6 +640,7 @@ func testConnectorCRUD(t *testing.T, s storage.Storage) {
Type: "Mock",
Name: "Mock",
Config: config2,
Hidden: false,
}

if err := s.CreateConnector(ctx, c2); err != nil {
Expand Down
1 change: 1 addition & 0 deletions storage/ent/client/connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ func (d *Database) CreateConnector(ctx context.Context, connector storage.Connec
SetType(connector.Type).
SetResourceVersion(connector.ResourceVersion).
SetConfig(connector.Config).
SetHidden(connector.Hidden).
Save(ctx)
if err != nil {
return convertDBError("create connector: %w", err)
Expand Down
15 changes: 14 additions & 1 deletion storage/ent/db/connector.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions storage/ent/db/connector/connector.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions storage/ent/db/connector/where.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 31 additions & 0 deletions storage/ent/db/connector_create.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 34 additions & 0 deletions storage/ent/db/connector_update.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions storage/ent/db/migrate/schema.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading