Browse Source

revert(api): remove reserved connector ID prefix check

The __client_credentials connector ID is no longer used since the
client_credentials grant now uses an empty connector ID. Remove the
__ prefix validation from CreateConnector and its associated test.

Signed-off-by: Mathias Gebbe <mathias.gebbe@gmail.com>
pull/4583/head
Mathias Gebbe 3 weeks ago
parent
commit
d9d679930d
No known key found for this signature in database
GPG Key ID: 2A35E2EC75E5438F
  1. 5
      server/api.go
  2. 15
      server/api_test.go

5
server/api.go

@ -7,7 +7,6 @@ import (
"fmt"
"log/slog"
"strconv"
"strings"
"golang.org/x/crypto/bcrypt"
@ -440,10 +439,6 @@ func (d dexAPI) CreateConnector(ctx context.Context, req *api.CreateConnectorReq
return nil, errors.New("no id supplied")
}
if strings.HasPrefix(req.Connector.Id, "__") {
return nil, fmt.Errorf("connector ID %q is invalid: IDs starting with \"__\" are reserved for internal use", req.Connector.Id)
}
if req.Connector.Type == "" {
return nil, errors.New("no type supplied")
}

15
server/api_test.go

@ -536,21 +536,6 @@ func TestCreateConnector(t *testing.T) {
} else if !strings.Contains(err.Error(), "invalid config supplied") {
t.Fatalf("Unexpected error: %v", err)
}
// Test reserved connector ID (__ prefix)
reservedReq := api.CreateConnectorReq{
Connector: &api.Connector{
Id: "__client_credentials",
Name: "Reserved",
Type: "TestType",
Config: []byte(`{"key": "value"}`),
},
}
if _, err := client.CreateConnector(ctx, &reservedReq); err == nil {
t.Fatal("Expected an error for reserved connector ID, but none occurred")
} else if !strings.Contains(err.Error(), "reserved for internal use") {
t.Fatalf("Unexpected error: %v", err)
}
}
func TestUpdateConnector(t *testing.T) {

Loading…
Cancel
Save