Compare commits
7 commits
c019ca2c41
...
aa2a4d42d8
Author | SHA1 | Date | |
---|---|---|---|
aa2a4d42d8 | |||
2404156e91 | |||
e00347d96f | |||
a82c12fc93 | |||
554d9bccc4 | |||
ccb417ad6a | |||
7b1150c00b |
10 changed files with 250 additions and 107 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
|
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]
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -40,12 +40,19 @@ const (
|
|||
ModeNet
|
||||
)
|
||||
|
||||
type BackendConfigType string
|
||||
|
||||
const (
|
||||
Memory BackendConfigType = "memory"
|
||||
SQLite BackendConfigType = "sqlite"
|
||||
)
|
||||
|
||||
type BackendConfig struct {
|
||||
Config *oidc.Config `json:"config"`
|
||||
Name string `json:"name"`
|
||||
ID string `json:"ID"`
|
||||
Type string `json:"type"`
|
||||
Local bool `json:"local"`
|
||||
Config *oidc.Config `json:"config"`
|
||||
Name string `json:"name"`
|
||||
ID string `json:"ID"`
|
||||
Type BackendConfigType `json:"type"`
|
||||
Local bool `json:"local"`
|
||||
}
|
||||
|
||||
type OpenConnectConfig struct {
|
||||
|
@ -54,6 +61,19 @@ type OpenConnectConfig struct {
|
|||
Issuer string `json:"issuer"`
|
||||
}
|
||||
|
||||
type StorageConfig 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 {
|
||||
Log struct {
|
||||
Level string `json:"level"`
|
||||
|
@ -64,6 +84,10 @@ type jsonConf struct {
|
|||
Mode string `json:"mode"`
|
||||
SockPath string `json:"sock"`
|
||||
} `json:"server"`
|
||||
Storage struct {
|
||||
StorageType string `json:"type"`
|
||||
Config *StorageConfig `json:"config"`
|
||||
} `json:"storage"`
|
||||
OpenConnectConfig *OpenConnectConfig `json:"openconnect"`
|
||||
}
|
||||
|
||||
|
@ -73,6 +97,8 @@ type AppConfig struct {
|
|||
Host string
|
||||
Port int
|
||||
SockPath string
|
||||
StorageType string
|
||||
StorageConfig *StorageConfig
|
||||
OpenConnectConfig *OpenConnectConfig
|
||||
}
|
||||
|
||||
|
@ -102,14 +128,17 @@ func (ac *AppConfig) UnmarshalJSON(data []byte) error {
|
|||
ac.Host = jsonConf.Server.Host
|
||||
ac.Port = jsonConf.Server.Port
|
||||
ac.OpenConnectConfig = jsonConf.OpenConnectConfig
|
||||
ac.StorageType = jsonConf.Storage.StorageType
|
||||
ac.StorageConfig = jsonConf.Storage.Config
|
||||
return nil
|
||||
}
|
||||
|
||||
var defaultConfig AppConfig = AppConfig{
|
||||
LogLevel: logrus.InfoLevel,
|
||||
ServerMode: ModeNet,
|
||||
Host: "0.0.0.0",
|
||||
Port: 5000,
|
||||
LogLevel: logrus.InfoLevel,
|
||||
ServerMode: ModeNet,
|
||||
Host: "0.0.0.0",
|
||||
Port: 5000,
|
||||
StorageType: "memory",
|
||||
}
|
||||
|
||||
func New(filepath string) (*AppConfig, error) {
|
||||
|
|
|
@ -4,6 +4,7 @@ import (
|
|||
"context"
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/signal"
|
||||
"time"
|
||||
|
@ -34,6 +35,17 @@ func parseArgs() *cliArgs {
|
|||
}
|
||||
}
|
||||
|
||||
func initStorage(conf *config.AppConfig) (storage.Storage, error) {
|
||||
var storageType storage.Storage
|
||||
switch conf.StorageType {
|
||||
case "memory":
|
||||
storageType = memory.New(logger.L)
|
||||
default:
|
||||
return storageType, fmt.Errorf("unsupported storage backend type: %s", conf.StorageType)
|
||||
}
|
||||
return storageType, nil
|
||||
}
|
||||
|
||||
func main() {
|
||||
args := parseArgs()
|
||||
|
||||
|
@ -47,12 +59,17 @@ func main() {
|
|||
logger.Init(conf.LogLevel)
|
||||
logger.L.Infof("Initialized logger with level %v", conf.LogLevel)
|
||||
|
||||
storageType, err := initStorage(conf)
|
||||
if err != nil {
|
||||
logger.L.Fatalf("Failed to initialize storage backend: %s", err.Error())
|
||||
}
|
||||
logger.L.Infof("Initialized storage backend %q", conf.StorageType)
|
||||
dexConf := dex_server.Config{
|
||||
Web: dex_server.WebConfig{
|
||||
Dir: "./",
|
||||
Theme: "default",
|
||||
},
|
||||
Storage: memory.New(logger.L),
|
||||
Storage: storageType,
|
||||
Issuer: conf.OpenConnectConfig.Issuer,
|
||||
SupportedResponseTypes: []string{"code"},
|
||||
SkipApprovalScreen: false,
|
||||
|
@ -82,7 +99,7 @@ func main() {
|
|||
if err := dexConf.Storage.CreateConnector(storage.Connector{
|
||||
ID: backend.ID,
|
||||
Name: backend.Name,
|
||||
Type: backend.Type,
|
||||
Type: string(backend.Type),
|
||||
Config: backendConfJson,
|
||||
}); err != nil {
|
||||
logger.L.Errorf("Failed to add connector for backend %q to stage: %s", backend.Name, err.Error())
|
||||
|
|
94
polyculeconnect/static/style/index.css
Normal file
94
polyculeconnect/static/style/index.css
Normal file
|
@ -0,0 +1,94 @@
|
|||
:root {
|
||||
--crust: #dce0e8;
|
||||
--mantle: #e6e9ef;
|
||||
--base: #eff1f5;
|
||||
--surface-0: #ccd0da;
|
||||
--surface-1: #bcc0cc;
|
||||
--surface-2: #acb0be;
|
||||
--overlay-0: #9ca0b0;
|
||||
--overlay-1: #8c8fa1;
|
||||
--overlay-2: #7c7f93;
|
||||
--subtext-0: #6c6f85;
|
||||
--subtext-1: #5c5f77;
|
||||
--text: #4c4f69;
|
||||
|
||||
--logo-purple: #340c46;
|
||||
--logo-yellow: #fcbf00;
|
||||
--logo-pink: #e50051;
|
||||
--logo-blue: #009fe3;
|
||||
}
|
||||
|
||||
body {
|
||||
background-color: var(--base);
|
||||
color: var(--text);
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.site-header {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
padding: 10px;
|
||||
margin-bottom: 40px;
|
||||
|
||||
.site-logo img {
|
||||
height: 100px;
|
||||
}
|
||||
}
|
||||
|
||||
.container {
|
||||
background-color: var(--mantle);
|
||||
display: grid;
|
||||
grid-template-columns: 1;
|
||||
row-gap: 20px;
|
||||
padding: 15px 50px;
|
||||
max-width: 50%;
|
||||
width: fit-content;
|
||||
margin: auto;
|
||||
border: 1px solid var(--surface-0);
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
.container-content {
|
||||
margin-bottom: 10px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.form-elements {
|
||||
display: grid;
|
||||
grid-template-columns: 1;
|
||||
row-gap: 10px;
|
||||
margin-bottom: 15px;
|
||||
padding: 0 10px;
|
||||
}
|
||||
|
||||
.form-buttons {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.form-input {
|
||||
width: 100%;
|
||||
padding: 5px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.form-input::placeholder {
|
||||
color: var(--subtext-1);
|
||||
}
|
||||
|
||||
.button {
|
||||
border: none;
|
||||
color: var(--mantle);
|
||||
padding: 5px 20px;
|
||||
border-radius: 3px;
|
||||
text-align: center;
|
||||
vertical-align: middle;
|
||||
text-decoration: none;
|
||||
display: inline-block;
|
||||
font-size: medium;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.button-accept {
|
||||
background-color: var(--logo-blue);
|
||||
}
|
|
@ -7,6 +7,8 @@
|
|||
<title>PolyculeConnect</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<link rel="stylesheet" href="/static/style/index.css">
|
||||
|
||||
<link rel="apple-touch-icon" sizes="180x180" href="/static/icons/apple-touch-icon.png">
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="/static/icons/favicon-32x32.png">
|
||||
<link rel="icon" type="image/png" sizes="16x16" href="/static/icons/favicon-16x16.png">
|
||||
|
@ -17,3 +19,10 @@
|
|||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div class="site-header">
|
||||
<div class="site-logo">
|
||||
<img src="/static/img/logo-text.png" alt="PolyculeConnect website logo">
|
||||
</div>
|
||||
|
||||
</div>
|
|
@ -2,12 +2,22 @@
|
|||
|
||||
<script src="/static/scripts/index.js" defer></script>
|
||||
|
||||
<div>
|
||||
<form action="" id="connectorform">
|
||||
<label for="cname">Connector name</label>
|
||||
<input type="text" id="cname" name="connector_id">
|
||||
<input type="submit">
|
||||
</form>
|
||||
<div class="container">
|
||||
<div class="container-content">
|
||||
Enter the service to use for login.
|
||||
</div>
|
||||
|
||||
<div class="container-content">
|
||||
<form action="" id="connectorform" class="container-form">
|
||||
<div class="form-elements">
|
||||
<input type="text" id="cname" name="connector_id" placeholder="Service name" required
|
||||
class="form-input">
|
||||
</div>
|
||||
<div class="form-buttons">
|
||||
<input type="submit" class="button button-accept" value="Continue">
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{ template "footer.html" . }}
|
Loading…
Reference in a new issue