Compare commits
4 commits
22cefb09d7
...
3bc17d6aba
Author | SHA1 | Date | |
---|---|---|---|
3bc17d6aba | |||
e00347d96f | |||
a82c12fc93 | |||
554d9bccc4 |
10 changed files with 129 additions and 193 deletions
88
.drone.yml
88
.drone.yml
|
@ -1,88 +0,0 @@
|
|||
---
|
||||
# Test building the code and docker image
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: test-build
|
||||
|
||||
steps:
|
||||
- name: go-test
|
||||
image: golang
|
||||
commands:
|
||||
- make -C polyculeconnect test
|
||||
depends_on:
|
||||
|
||||
- name: go-build
|
||||
image: golang
|
||||
commands:
|
||||
- make -C polyculeconnect build
|
||||
depends_on:
|
||||
|
||||
- name: docker-build-only
|
||||
image: thegeeklab/drone-docker-buildx
|
||||
privileged: true
|
||||
settings:
|
||||
repo: git.faercol.me/polyculeconnect/polyculeconnect
|
||||
tags: latest
|
||||
dry_run: true
|
||||
platforms:
|
||||
- linux/amd64
|
||||
# - linux/arm64
|
||||
depends_on:
|
||||
when:
|
||||
branch:
|
||||
exclude:
|
||||
- main
|
||||
|
||||
- name: docker-build-push
|
||||
image: thegeeklab/drone-docker-buildx
|
||||
privileged: true
|
||||
settings:
|
||||
repo: git.faercol.me/polyculeconnect/polyculeconnect
|
||||
registry: git.faercol.me
|
||||
tags: latest
|
||||
username:
|
||||
from_secret: GIT_USERNAME
|
||||
password:
|
||||
from_secret: GIT_PASSWORD
|
||||
platforms:
|
||||
- linux/amd64
|
||||
# - linux/arm64
|
||||
depends_on:
|
||||
- go-test
|
||||
- go-build
|
||||
when:
|
||||
branch:
|
||||
- main
|
||||
|
||||
trigger:
|
||||
event:
|
||||
- push
|
||||
- tag
|
||||
|
||||
---
|
||||
# On a tag, only build the related docker image
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: tag-release
|
||||
depends_on:
|
||||
- test-build
|
||||
|
||||
steps:
|
||||
- name: docker-push-tag
|
||||
image: thegeeklab/drone-docker-buildx
|
||||
privileged: true
|
||||
settings:
|
||||
registry: git.faercol.me
|
||||
repo: git.faercol.me/polyculeconnect/polyculeconnect
|
||||
auto_tag: true
|
||||
platforms:
|
||||
- linux/amd64
|
||||
# - linux/arm64
|
||||
username:
|
||||
from_secret: GIT_USERNAME
|
||||
password:
|
||||
from_secret: GIT_PASSWORD
|
||||
|
||||
trigger:
|
||||
event:
|
||||
- tag
|
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -23,3 +23,5 @@ go.work
|
|||
|
||||
# Go build file
|
||||
**/build/
|
||||
|
||||
.vscode
|
|
@ -1,88 +0,0 @@
|
|||
---
|
||||
# Test building the code and docker image
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: test-build
|
||||
|
||||
steps:
|
||||
- name: go-test
|
||||
image: golang
|
||||
commands:
|
||||
- make -C polyculeconnect test
|
||||
depends_on:
|
||||
|
||||
- name: go-build
|
||||
image: golang
|
||||
commands:
|
||||
- make -C polyculeconnect build
|
||||
depends_on:
|
||||
|
||||
- name: docker-build-only
|
||||
image: thegeeklab/drone-docker-buildx
|
||||
privileged: true
|
||||
settings:
|
||||
repo: git.faercol.me/polyculeconnect/polyculeconnect
|
||||
tags: latest
|
||||
dry_run: true
|
||||
platforms:
|
||||
- linux/amd64
|
||||
# - linux/arm64
|
||||
depends_on:
|
||||
when:
|
||||
branch:
|
||||
exclude:
|
||||
- main
|
||||
|
||||
- name: docker-build-push
|
||||
image: thegeeklab/drone-docker-buildx
|
||||
privileged: true
|
||||
settings:
|
||||
repo: git.faercol.me/polyculeconnect/polyculeconnect
|
||||
registry: git.faercol.me
|
||||
tags: latest
|
||||
username:
|
||||
from_secret: GIT_USERNAME
|
||||
password:
|
||||
from_secret: GIT_PASSWORD
|
||||
platforms:
|
||||
- linux/amd64
|
||||
# - linux/arm64
|
||||
depends_on:
|
||||
- go-test
|
||||
- go-build
|
||||
when:
|
||||
branch:
|
||||
- main
|
||||
|
||||
trigger:
|
||||
event:
|
||||
- push
|
||||
- tag
|
||||
|
||||
---
|
||||
# On a tag, only build the related docker image
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: tag-release
|
||||
depends_on:
|
||||
- test-build
|
||||
|
||||
steps:
|
||||
- name: docker-push-tag
|
||||
image: thegeeklab/drone-docker-buildx
|
||||
privileged: true
|
||||
settings:
|
||||
registry: git.faercol.me
|
||||
repo: git.faercol.me/polyculeconnect/polyculeconnect
|
||||
auto_tag: true
|
||||
platforms:
|
||||
- linux/amd64
|
||||
# - linux/arm64
|
||||
username:
|
||||
from_secret: GIT_USERNAME
|
||||
password:
|
||||
from_secret: GIT_PASSWORD
|
||||
|
||||
trigger:
|
||||
event:
|
||||
- tag
|
57
.woodpecker/deploy.yml
Normal file
57
.woodpecker/deploy.yml
Normal file
|
@ -0,0 +1,57 @@
|
|||
steps:
|
||||
docker-build-only:
|
||||
image: woodpeckerci/plugin-docker-buildx
|
||||
privileged: true
|
||||
settings:
|
||||
repo: git.faercol.me/polyculeconnect/polyculeconnect
|
||||
tags: latest
|
||||
dry_run: true
|
||||
platforms:
|
||||
- linux/amd64
|
||||
# - linux/arm64
|
||||
when:
|
||||
- event: pull_request
|
||||
- event: push
|
||||
branch:
|
||||
exclude: [main]
|
||||
|
||||
docker-build-push:
|
||||
image: woodpeckerci/plugin-docker-buildx
|
||||
privileged: true
|
||||
settings:
|
||||
repo: git.faercol.me/polyculeconnect/polyculeconnect
|
||||
registry: git.faercol.me
|
||||
tags: latest
|
||||
username:
|
||||
from_secret: git_username
|
||||
password:
|
||||
from_secret: git_password
|
||||
platforms:
|
||||
- linux/amd64
|
||||
# - linux/arm64
|
||||
when:
|
||||
- event: push
|
||||
branch: main
|
||||
|
||||
docker-push-tag:
|
||||
image: woodpeckerci/plugin-docker-buildx
|
||||
privileged: true
|
||||
settings:
|
||||
registry: git.faercol.me
|
||||
repo: git.faercol.me/polyculeconnect/polyculeconnect
|
||||
auto_tag: true
|
||||
platforms:
|
||||
- linux/amd64
|
||||
# - linux/arm64
|
||||
username:
|
||||
from_secret: git_username
|
||||
password:
|
||||
from_secret: git_password
|
||||
when:
|
||||
- event: tag
|
||||
|
||||
depends_on:
|
||||
- test
|
||||
|
||||
when:
|
||||
event: [push, tag]
|
13
.woodpecker/test.yml
Normal file
13
.woodpecker/test.yml
Normal file
|
@ -0,0 +1,13 @@
|
|||
steps:
|
||||
go-test:
|
||||
image: golang
|
||||
commands:
|
||||
- make -C polyculeconnect test
|
||||
|
||||
go-build:
|
||||
image: golang
|
||||
commands:
|
||||
- make -C polyculeconnect build
|
||||
|
||||
when:
|
||||
event: [push, tag]
|
|
@ -3,7 +3,7 @@ ARG TARGETPLATFORM
|
|||
ARG BUILDPLATFORM
|
||||
WORKDIR /go/src/git.faercol.me/polyculeconnect
|
||||
COPY polyculeconnect ./
|
||||
RUN CGO_ENABLED=0 make build
|
||||
RUN make build
|
||||
|
||||
# Replace with from scratch later on
|
||||
FROM --platform=$TARGETPLATFORM alpine:latest
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# PolyculeConnect
|
||||
|
||||
[![Build Status](https://drone.faercol.me/api/badges/PolyculeConnect/polycule-connect/status.svg)](https://drone.faercol.me/PolyculeConnect/polycule-connect)
|
||||
[![status-badge](https://ci-polycule-connect.chapoline.me/api/badges/1/status.svg)](https://ci-polycule-connect.chapoline.me/repos/1)
|
||||
|
||||
![Project logo](./polyculeconnect/static/img/logo-text.png)
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ require (
|
|||
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-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/protobuf v1.5.3 // 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/imdario/mergo v0.3.11 // 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/mattn/go-sqlite3 v1.14.17 // indirect
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
|
||||
github.com/mitchellh/copystructure 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-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-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/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=
|
||||
|
@ -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/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
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/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/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4=
|
||||
github.com/mitchellh/copystructure v1.0.0 h1:Laisrj+bAB6b/yJwB5Bt3ITZhGJdqmxquMKeZ+mmkFQ=
|
||||
|
|
|
@ -13,9 +13,11 @@ import (
|
|||
"git.faercol.me/faercol/polyculeconnect/polyculeconnect/connector"
|
||||
"git.faercol.me/faercol/polyculeconnect/polyculeconnect/logger"
|
||||
"git.faercol.me/faercol/polyculeconnect/polyculeconnect/server"
|
||||
"github.com/dexidp/dex/connector/oidc"
|
||||
dex_server "github.com/dexidp/dex/server"
|
||||
"github.com/dexidp/dex/storage"
|
||||
"github.com/dexidp/dex/storage/memory"
|
||||
"github.com/dexidp/dex/storage/sql"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
)
|
||||
|
||||
|
@ -37,15 +39,43 @@ func parseArgs() *cliArgs {
|
|||
|
||||
func initStorage(conf *config.AppConfig) (storage.Storage, error) {
|
||||
var storageType storage.Storage
|
||||
var err error
|
||||
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:
|
||||
return storageType, fmt.Errorf("unsupported storage backend type: %s", conf.StorageType)
|
||||
}
|
||||
return storageType, nil
|
||||
}
|
||||
|
||||
func createConnector(backend *config.BackendConfig, dexConf *dex_server.Config, connectorIDs []string) error {
|
||||
for _, id := range connectorIDs {
|
||||
if id == backend.ID {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
backendConfJson, err := json.Marshal(backend.Config)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to serialize oidc config for backend %q: %s", backend.Name, err.Error())
|
||||
}
|
||||
return dexConf.Storage.CreateConnector(storage.Connector{
|
||||
ID: backend.ID,
|
||||
Name: backend.Name,
|
||||
Type: string(backend.Type),
|
||||
Config: backendConfJson,
|
||||
})
|
||||
}
|
||||
|
||||
func main() {
|
||||
args := parseArgs()
|
||||
|
||||
|
@ -81,27 +111,28 @@ 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",
|
||||
connectors, err := dexConf.Storage.ListConnectors()
|
||||
if err != nil {
|
||||
logger.L.Fatalf("Failed to get existing connectors: %s", err.Error())
|
||||
}
|
||||
var connectorIDs []string
|
||||
for _, conn := range connectors {
|
||||
connectorIDs = append(connectorIDs, conn.ID)
|
||||
}
|
||||
|
||||
backend := config.BackendConfig{
|
||||
Config: &oidc.Config{},
|
||||
Name: "RefuseAll",
|
||||
ID: "null",
|
||||
Type: "refuseAll",
|
||||
Config: nil,
|
||||
}); err != nil {
|
||||
}
|
||||
|
||||
if err := createConnector(&backend, &dexConf, connectorIDs); err != nil {
|
||||
logger.L.Errorf("Failed to add connector for backend RefuseAll to stage: %s", err.Error())
|
||||
}
|
||||
|
||||
for _, backend := range conf.OpenConnectConfig.BackendConfigs {
|
||||
backendConfJson, err := json.Marshal(backend.Config)
|
||||
if err != nil {
|
||||
logger.L.Errorf("Failed to serialize oidc config for backend %q: %s", backend.Name, err.Error())
|
||||
continue
|
||||
}
|
||||
if err := dexConf.Storage.CreateConnector(storage.Connector{
|
||||
ID: backend.ID,
|
||||
Name: backend.Name,
|
||||
Type: string(backend.Type),
|
||||
Config: backendConfJson,
|
||||
}); err != nil {
|
||||
if err := createConnector(backend, &dexConf, connectorIDs); err != nil {
|
||||
logger.L.Errorf("Failed to add connector for backend %q to stage: %s", backend.Name, err.Error())
|
||||
continue
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue