From ddb3fd3e176cae2f261a4a8525b56ee7401738ab Mon Sep 17 00:00:00 2001 From: chapeau Date: Sat, 21 Oct 2023 21:36:50 +0200 Subject: [PATCH] feat: #31 --- polyculeconnect/connector/refuse_all.go | 25 +++++++++++++++++++++++++ polyculeconnect/main.go | 12 ++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 polyculeconnect/connector/refuse_all.go diff --git a/polyculeconnect/connector/refuse_all.go b/polyculeconnect/connector/refuse_all.go new file mode 100644 index 0000000..94c417e --- /dev/null +++ b/polyculeconnect/connector/refuse_all.go @@ -0,0 +1,25 @@ +package connector + +import ( + "fmt" + "net/http" + + "github.com/dexidp/dex/connector" + "github.com/dexidp/dex/pkg/log" +) + +type RefuseAllConfig struct{} + +func (c *RefuseAllConfig) Open(id string, logger log.Logger) (connector.Connector, error) { + return &RefuseAllConnector{}, nil +} + +type RefuseAllConnector struct{} + +func (m *RefuseAllConnector) LoginURL(s connector.Scopes, callbackURL, state string) (string, error) { + return "", fmt.Errorf("You shouldn't use this function") +} + +func (m *RefuseAllConnector) HandleCallback(s connector.Scopes, r *http.Request) (identity connector.Identity, err error) { + return connector.Identity{}, fmt.Errorf("You shouldn't use this function") +} diff --git a/polyculeconnect/main.go b/polyculeconnect/main.go index 58845ed..906228b 100644 --- a/polyculeconnect/main.go +++ b/polyculeconnect/main.go @@ -9,6 +9,7 @@ import ( "time" "git.faercol.me/faercol/polyculeconnect/polyculeconnect/config" + "git.faercol.me/faercol/polyculeconnect/polyculeconnect/connector" "git.faercol.me/faercol/polyculeconnect/polyculeconnect/logger" "git.faercol.me/faercol/polyculeconnect/polyculeconnect/server" dex_server "github.com/dexidp/dex/server" @@ -61,6 +62,17 @@ func main() { } logger.L.Info("Initializing authentication backends") + + dex_server.ConnectorsConfig["refuseAll"] = func() dex_server.ConnectorConfig { return new(connector.RefuseAllConfig) } + if err := dexConf.Storage.CreateConnector(storage.Connector{ + ID: "null", + Name: "RefuseAll", + Type: "refuseAll", + Config: nil, + }); err != nil { + logger.L.Errorf("Failed to add connector for backend RefuseAll to stage: %s", err) + } + for _, backend := range conf.OpenConnectConfig.BackendConfigs { backendConfJson, err := json.Marshal(backend.Config) if err != nil {