Compare commits
3 commits
59547ebe38
...
b18d481f03
Author | SHA1 | Date | |
---|---|---|---|
b18d481f03 | |||
0e41483302 | |||
a6011106d5 |
5 changed files with 56 additions and 6 deletions
|
@ -3,7 +3,7 @@ ARG TARGETPLATFORM
|
||||||
ARG BUILDPLATFORM
|
ARG BUILDPLATFORM
|
||||||
WORKDIR /go/src/git.faercol.me/polyculeconnect
|
WORKDIR /go/src/git.faercol.me/polyculeconnect
|
||||||
COPY polyculeconnect ./
|
COPY polyculeconnect ./
|
||||||
RUN CGO_ENABLED=0 make build
|
RUN make build
|
||||||
|
|
||||||
# Replace with from scratch later on
|
# Replace with from scratch later on
|
||||||
FROM --platform=$TARGETPLATFORM alpine:latest
|
FROM --platform=$TARGETPLATFORM alpine:latest
|
||||||
|
|
|
@ -54,6 +54,19 @@ type OpenConnectConfig struct {
|
||||||
Issuer string `json:"issuer"`
|
Issuer string `json:"issuer"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type StorageConfigConfig struct {
|
||||||
|
File string `json:"file"`
|
||||||
|
Host string `json:"host"`
|
||||||
|
Port int `json:"port"`
|
||||||
|
Database string `json:"database"`
|
||||||
|
User string `json:"user"`
|
||||||
|
Password string `json:"password"`
|
||||||
|
Ssl struct {
|
||||||
|
Mode string `json:"mode"`
|
||||||
|
CaFile string `json:"caFile"`
|
||||||
|
} `json:"ssl"`
|
||||||
|
}
|
||||||
|
|
||||||
type jsonConf struct {
|
type jsonConf struct {
|
||||||
Log struct {
|
Log struct {
|
||||||
Level string `json:"level"`
|
Level string `json:"level"`
|
||||||
|
@ -64,6 +77,10 @@ type jsonConf struct {
|
||||||
Mode string `json:"mode"`
|
Mode string `json:"mode"`
|
||||||
SockPath string `json:"sock"`
|
SockPath string `json:"sock"`
|
||||||
} `json:"server"`
|
} `json:"server"`
|
||||||
|
Storage struct {
|
||||||
|
StorageType string `json:"type"`
|
||||||
|
StorageConfig *StorageConfigConfig `json:"config"`
|
||||||
|
} `json:"storage"`
|
||||||
OpenConnectConfig *OpenConnectConfig `json:"openconnect"`
|
OpenConnectConfig *OpenConnectConfig `json:"openconnect"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,6 +90,8 @@ type AppConfig struct {
|
||||||
Host string
|
Host string
|
||||||
Port int
|
Port int
|
||||||
SockPath string
|
SockPath string
|
||||||
|
StorageType string
|
||||||
|
StorageConfig *StorageConfigConfig
|
||||||
OpenConnectConfig *OpenConnectConfig
|
OpenConnectConfig *OpenConnectConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,14 +121,17 @@ func (ac *AppConfig) UnmarshalJSON(data []byte) error {
|
||||||
ac.Host = jsonConf.Server.Host
|
ac.Host = jsonConf.Server.Host
|
||||||
ac.Port = jsonConf.Server.Port
|
ac.Port = jsonConf.Server.Port
|
||||||
ac.OpenConnectConfig = jsonConf.OpenConnectConfig
|
ac.OpenConnectConfig = jsonConf.OpenConnectConfig
|
||||||
|
ac.StorageType = jsonConf.Storage.StorageType
|
||||||
|
ac.StorageConfig = jsonConf.Storage.StorageConfig
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var defaultConfig AppConfig = AppConfig{
|
var defaultConfig AppConfig = AppConfig{
|
||||||
LogLevel: logrus.InfoLevel,
|
LogLevel: logrus.InfoLevel,
|
||||||
ServerMode: ModeNet,
|
ServerMode: ModeNet,
|
||||||
Host: "0.0.0.0",
|
Host: "0.0.0.0",
|
||||||
Port: 5000,
|
Port: 5000,
|
||||||
|
StorageType: "memory",
|
||||||
}
|
}
|
||||||
|
|
||||||
func New(filepath string) (*AppConfig, error) {
|
func New(filepath string) (*AppConfig, error) {
|
||||||
|
|
|
@ -27,6 +27,7 @@ require (
|
||||||
github.com/go-asn1-ber/asn1-ber v1.5.5 // indirect
|
github.com/go-asn1-ber/asn1-ber v1.5.5 // indirect
|
||||||
github.com/go-jose/go-jose/v3 v3.0.0 // indirect
|
github.com/go-jose/go-jose/v3 v3.0.0 // indirect
|
||||||
github.com/go-ldap/ldap/v3 v3.4.6 // indirect
|
github.com/go-ldap/ldap/v3 v3.4.6 // indirect
|
||||||
|
github.com/go-sql-driver/mysql v1.7.1 // indirect
|
||||||
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
|
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
|
||||||
github.com/golang/protobuf v1.5.3 // indirect
|
github.com/golang/protobuf v1.5.3 // indirect
|
||||||
github.com/google/s2a-go v0.1.7 // indirect
|
github.com/google/s2a-go v0.1.7 // indirect
|
||||||
|
@ -38,7 +39,9 @@ require (
|
||||||
github.com/huandu/xstrings v1.3.3 // indirect
|
github.com/huandu/xstrings v1.3.3 // indirect
|
||||||
github.com/imdario/mergo v0.3.11 // indirect
|
github.com/imdario/mergo v0.3.11 // indirect
|
||||||
github.com/jonboulle/clockwork v0.2.2 // indirect
|
github.com/jonboulle/clockwork v0.2.2 // indirect
|
||||||
|
github.com/lib/pq v1.10.9 // indirect
|
||||||
github.com/mattermost/xml-roundtrip-validator v0.1.0 // indirect
|
github.com/mattermost/xml-roundtrip-validator v0.1.0 // indirect
|
||||||
|
github.com/mattn/go-sqlite3 v1.14.17 // indirect
|
||||||
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
|
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
|
||||||
github.com/mitchellh/copystructure v1.0.0 // indirect
|
github.com/mitchellh/copystructure v1.0.0 // indirect
|
||||||
github.com/mitchellh/reflectwalk v1.0.0 // indirect
|
github.com/mitchellh/reflectwalk v1.0.0 // indirect
|
||||||
|
|
|
@ -51,6 +51,8 @@ github.com/go-jose/go-jose/v3 v3.0.0 h1:s6rrhirfEP/CGIoc6p+PZAeogN2SxKav6Wp7+dyM
|
||||||
github.com/go-jose/go-jose/v3 v3.0.0/go.mod h1:RNkWWRld676jZEYoV3+XK8L2ZnNSvIsxFMht0mSX+u8=
|
github.com/go-jose/go-jose/v3 v3.0.0/go.mod h1:RNkWWRld676jZEYoV3+XK8L2ZnNSvIsxFMht0mSX+u8=
|
||||||
github.com/go-ldap/ldap/v3 v3.4.6 h1:ert95MdbiG7aWo/oPYp9btL3KJlMPKnP58r09rI8T+A=
|
github.com/go-ldap/ldap/v3 v3.4.6 h1:ert95MdbiG7aWo/oPYp9btL3KJlMPKnP58r09rI8T+A=
|
||||||
github.com/go-ldap/ldap/v3 v3.4.6/go.mod h1:IGMQANNtxpsOzj7uUAMjpGBaOVTC4DYyIy8VsTdxmtc=
|
github.com/go-ldap/ldap/v3 v3.4.6/go.mod h1:IGMQANNtxpsOzj7uUAMjpGBaOVTC4DYyIy8VsTdxmtc=
|
||||||
|
github.com/go-sql-driver/mysql v1.7.1 h1:lUIinVbN1DY0xBg0eMOzmmtGoHwWBbvnWubQUrtU8EI=
|
||||||
|
github.com/go-sql-driver/mysql v1.7.1/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI=
|
||||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||||
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||||
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE=
|
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE=
|
||||||
|
@ -106,8 +108,12 @@ github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||||
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
|
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
|
||||||
|
github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw=
|
||||||
|
github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
|
||||||
github.com/mattermost/xml-roundtrip-validator v0.1.0 h1:RXbVD2UAl7A7nOTR4u7E3ILa4IbtvKBHw64LDsmu9hU=
|
github.com/mattermost/xml-roundtrip-validator v0.1.0 h1:RXbVD2UAl7A7nOTR4u7E3ILa4IbtvKBHw64LDsmu9hU=
|
||||||
github.com/mattermost/xml-roundtrip-validator v0.1.0/go.mod h1:qccnGMcpgwcNaBnxqpJpWWUiPNr5H3O8eDgGV9gT5To=
|
github.com/mattermost/xml-roundtrip-validator v0.1.0/go.mod h1:qccnGMcpgwcNaBnxqpJpWWUiPNr5H3O8eDgGV9gT5To=
|
||||||
|
github.com/mattn/go-sqlite3 v1.14.17 h1:mCRHCLDUBXgpKAqIKsaAaAsrAlbkeomtRFKXh2L6YIM=
|
||||||
|
github.com/mattn/go-sqlite3 v1.14.17/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg=
|
||||||
github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo=
|
github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo=
|
||||||
github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4=
|
github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4=
|
||||||
github.com/mitchellh/copystructure v1.0.0 h1:Laisrj+bAB6b/yJwB5Bt3ITZhGJdqmxquMKeZ+mmkFQ=
|
github.com/mitchellh/copystructure v1.0.0 h1:Laisrj+bAB6b/yJwB5Bt3ITZhGJdqmxquMKeZ+mmkFQ=
|
||||||
|
|
|
@ -15,6 +15,7 @@ import (
|
||||||
dex_server "github.com/dexidp/dex/server"
|
dex_server "github.com/dexidp/dex/server"
|
||||||
"github.com/dexidp/dex/storage"
|
"github.com/dexidp/dex/storage"
|
||||||
"github.com/dexidp/dex/storage/memory"
|
"github.com/dexidp/dex/storage/memory"
|
||||||
|
"github.com/dexidp/dex/storage/sql"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -47,12 +48,30 @@ func main() {
|
||||||
logger.Init(conf.LogLevel)
|
logger.Init(conf.LogLevel)
|
||||||
logger.L.Infof("Initialized logger with level %v", conf.LogLevel)
|
logger.L.Infof("Initialized logger with level %v", conf.LogLevel)
|
||||||
|
|
||||||
|
var storageType storage.Storage
|
||||||
|
switch conf.StorageType {
|
||||||
|
case "memory":
|
||||||
|
storageType = memory.New(logger.L)
|
||||||
|
case "sqlite":
|
||||||
|
sqlconfig := sql.SQLite3{
|
||||||
|
File: conf.StorageConfig.File,
|
||||||
|
}
|
||||||
|
storageType, err = sqlconfig.Open(logger.L)
|
||||||
|
if err != nil {
|
||||||
|
logger.L.Fatalf("Failed to initialize sqlite backend: %s", err.Error())
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
logger.L.Fatalf("Unsupported storage backend type: %s", conf.StorageType)
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.L.Infof("Initialized storage backend \"%s\"", conf.StorageType)
|
||||||
|
|
||||||
dexConf := dex_server.Config{
|
dexConf := dex_server.Config{
|
||||||
Web: dex_server.WebConfig{
|
Web: dex_server.WebConfig{
|
||||||
Dir: "./",
|
Dir: "./",
|
||||||
Theme: "default",
|
Theme: "default",
|
||||||
},
|
},
|
||||||
Storage: memory.New(logger.L),
|
Storage: storageType,
|
||||||
Issuer: conf.OpenConnectConfig.Issuer,
|
Issuer: conf.OpenConnectConfig.Issuer,
|
||||||
SupportedResponseTypes: []string{"code"},
|
SupportedResponseTypes: []string{"code"},
|
||||||
SkipApprovalScreen: false,
|
SkipApprovalScreen: false,
|
||||||
|
|
Loading…
Reference in a new issue