Compare commits
10 Commits
2113e8eade
...
v0.0.1
| Author | SHA1 | Date | |
|---|---|---|---|
| 2f297fd935 | |||
| eee5cb2fef | |||
| 6d5c7141fb | |||
| cf08c9e928 | |||
| 2a8cb0bb54 | |||
| 3e4ae9cf27 | |||
| 57e35bc202 | |||
| cb01f7554a | |||
| 12869d1ec0 | |||
| 0341c7c6b3 |
@@ -13,6 +13,7 @@ builds:
|
||||
- 386
|
||||
- arm64
|
||||
- arm
|
||||
- riscv64
|
||||
archives:
|
||||
- id: archive
|
||||
name_template: "{{ .ProjectName }}-{{ .Arch }}"
|
||||
|
||||
@@ -17,5 +17,4 @@ pipeline:
|
||||
- PLUGIN_WATCH_DEPLOYMENT=true
|
||||
- PLUGIN_WATCH_DEPLOYMENT_TIMEOUT=10m
|
||||
when:
|
||||
branch: public
|
||||
event: push
|
||||
event: tag
|
||||
@@ -41,6 +41,7 @@ var (
|
||||
ErrInvalidHdrVal = errors.New("invalid header value type")
|
||||
ErrInvalidType = errors.New("invalid type")
|
||||
ErrInsecureWebhook = errors.New("secure webhook missing authorization")
|
||||
ErrIncorrectPassword = errors.New("incorrect password")
|
||||
)
|
||||
|
||||
var httpModule = &starlarkstruct.Module{
|
||||
@@ -352,10 +353,8 @@ func verifySecure(pwdHash, pluginName string, req *http.Request) error {
|
||||
return ErrInsecureWebhook
|
||||
}
|
||||
|
||||
fmt.Println(string(pwd))
|
||||
|
||||
if err := bcrypt.CompareHashAndPassword([]byte(pwdHash), pwd); err != nil {
|
||||
return err
|
||||
return ErrIncorrectPassword
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
10
main.go
10
main.go
@@ -41,7 +41,6 @@ import (
|
||||
|
||||
func init() {
|
||||
log.Logger = logger.NewPretty(os.Stderr)
|
||||
log.Logger.SetLevel(logger.LogLevelDebug)
|
||||
}
|
||||
|
||||
func main() {
|
||||
@@ -51,8 +50,13 @@ func main() {
|
||||
serverAddr := pflag.StringP("address", "a", ":8080", "Webhook server address")
|
||||
genHash := pflag.BoolP("gen-hash", "g", false, "Generate a password hash for webhooks")
|
||||
useEnv := pflag.BoolP("use-env", "E", false, "Use environment variables for configuration")
|
||||
debug := pflag.BoolP("debug", "D", false, "Enable debug logging")
|
||||
pflag.Parse()
|
||||
|
||||
if *debug {
|
||||
log.Logger.SetLevel(logger.LogLevelDebug)
|
||||
}
|
||||
|
||||
if *genHash {
|
||||
fmt.Print("Password: ")
|
||||
pwd, err := term.ReadPassword(int(os.Stdin.Fd()))
|
||||
@@ -87,6 +91,10 @@ func main() {
|
||||
if err != nil {
|
||||
log.Fatal("Error decoding config file").Err(err).Send()
|
||||
}
|
||||
err = fl.Close()
|
||||
if err != nil {
|
||||
log.Fatal("Error closing config file").Err(err).Send()
|
||||
}
|
||||
}
|
||||
|
||||
if _, err := os.Stat(cfg.Git.RepoDir); os.IsNotExist(err) {
|
||||
|
||||
@@ -11,8 +11,8 @@ job "lure-updater" {
|
||||
}
|
||||
|
||||
volume "lure-updater-data" {
|
||||
type = "host"
|
||||
source = "lure-updater-data"
|
||||
type = "host"
|
||||
source = "lure-updater-data"
|
||||
read_only = false
|
||||
}
|
||||
|
||||
@@ -20,20 +20,20 @@ job "lure-updater" {
|
||||
driver = "docker"
|
||||
|
||||
volume_mount {
|
||||
volume = "lure-updater-data"
|
||||
volume = "lure-updater-data"
|
||||
destination = "/etc/lure-updater"
|
||||
read_only = false
|
||||
read_only = false
|
||||
}
|
||||
|
||||
env {
|
||||
GIT_REPO_DIR="/etc/lure-updater/repo"
|
||||
GIT_REPO_URL="https://github.com/Elara6331/lure-repo.git"
|
||||
GIT_CREDENTIALS_USERNAME="lure-repo-bot"
|
||||
GIT_CREDENTIALS_PASSWORD="${GITHUB_PASSWORD}"
|
||||
GIT_COMMIT_NAME="lure-repo-bot"
|
||||
GIT_COMMIT_EMAIL="lure@elara.ws"
|
||||
WEBHOOK_PASSWORD_HASH="${PASSWORD_HASH}"
|
||||
|
||||
GIT_REPO_DIR = "/etc/lure-updater/repo"
|
||||
GIT_REPO_URL = "https://github.com/Elara6331/lure-repo.git"
|
||||
GIT_CREDENTIALS_USERNAME = "lure-repo-bot"
|
||||
GIT_CREDENTIALS_PASSWORD = "${GITHUB_PASSWORD}"
|
||||
GIT_COMMIT_NAME = "lure-repo-bot"
|
||||
GIT_COMMIT_EMAIL = "lure@elara.ws"
|
||||
WEBHOOK_PASSWORD_HASH = "${PASSWORD_HASH}"
|
||||
|
||||
// Hack to force Nomad to re-deploy the service
|
||||
// instead of ignoring it
|
||||
COMMIT_SHA = "${DRONE_COMMIT_SHA}"
|
||||
@@ -41,10 +41,10 @@ job "lure-updater" {
|
||||
|
||||
config {
|
||||
image = "alpine:latest"
|
||||
command = "/opt/lure-updater/lure-updater"
|
||||
args = ["-DE"]
|
||||
ports = ["webhook"]
|
||||
volumes = ["local/lure-updater/:/opt/lure-updater:ro"]
|
||||
command = "/opt/lure-updater/lure-updater"
|
||||
args = ["-E"]
|
||||
}
|
||||
|
||||
artifact {
|
||||
|
||||
Reference in New Issue
Block a user