From 3791b5ee486ce0487517100750a8fc7b76950c42 Mon Sep 17 00:00:00 2001 From: Finn Date: Tue, 23 Apr 2024 19:05:37 -0700 Subject: [PATCH] drop unused session secrets --- Containerfile | 2 +- config/config.go | 26 +++----------------------- go.mod | 1 - go.sum | 4 ---- lockserver.defaults.json | 3 +-- 5 files changed, 5 insertions(+), 31 deletions(-) diff --git a/Containerfile b/Containerfile index e20ca8b..daac51e 100644 --- a/Containerfile +++ b/Containerfile @@ -17,7 +17,7 @@ FROM library/golang:1.21 AS build ADD . /go/lockserver WORKDIR /go/lockserver -RUN CGO_ENABLED=0 go build . +RUN CGO_ENABLED=0 go build ./cmd/lockserver FROM scratch COPY --from=build /go/lockserver/lockserver /lockserver diff --git a/config/config.go b/config/config.go index e33118e..ad230e6 100644 --- a/config/config.go +++ b/config/config.go @@ -1,27 +1,23 @@ package config import ( - "encoding/base64" "encoding/json" "errors" "os" - "github.com/gorilla/securecookie" "github.com/sirupsen/logrus" ) type Config struct { - ZWaveJSServer string `json:"zwave-js-server"` - SqliteDatabase string `json:"sqlite-database"` - HTTPBind string `json:"http-bind"` - SessionSecrets []JSONBytes `json:"session-secrets"` + ZWaveJSServer string `json:"zwave-js-server"` + SqliteDatabase string `json:"sqlite-database"` + HTTPBind string `json:"http-bind"` } var C = Config{ ZWaveJSServer: "ws://home-assistant:3000", SqliteDatabase: "lockserver.db", HTTPBind: ":8080", - SessionSecrets: []JSONBytes{}, } var configFiles = []string{"lockserver.json", "/etc/lockserver.json"} @@ -38,14 +34,6 @@ func Load() error { logrus.WithField("file", path).Info("loaded config") } - if len(C.SessionSecrets) == 0 { - logrus.WithFields(logrus.Fields{ - "rand_64": base64.URLEncoding.EncodeToString(securecookie.GenerateRandomKey(64)), - "rand_32": base64.URLEncoding.EncodeToString(securecookie.GenerateRandomKey(32)), - }).Info("some potential session secrets for you (hint: use both)") - return errors.New("no session secrets defined, some possible values have been logged") - } - return nil } @@ -62,11 +50,3 @@ func load(path string) error { return nil } - -func (c Config) GetSessionSecrets() [][]byte { - var resp [][]byte - for _, s := range c.SessionSecrets { - resp = append(resp, s.AsByteArrayArray()) - } - return resp -} diff --git a/go.mod b/go.mod index 25b2fcd..cba4bb2 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,6 @@ require ( github.com/failsafe-go/failsafe-go v0.6.2 github.com/getkin/kin-openapi v0.124.0 github.com/google/uuid v1.6.0 - github.com/gorilla/securecookie v1.1.2 github.com/gorilla/websocket v1.5.1 github.com/labstack/echo/v4 v4.11.4 github.com/mattn/go-sqlite3 v1.14.22 diff --git a/go.sum b/go.sum index 081c829..c9eb1e8 100644 --- a/go.sum +++ b/go.sum @@ -62,14 +62,10 @@ github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOW github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= -github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4= github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/gorilla/securecookie v1.1.2 h1:YCIWL56dvtr73r6715mJs5ZvhtnY73hBvEF8kXD8ePA= -github.com/gorilla/securecookie v1.1.2/go.mod h1:NfCASbcHqRSY+3a8tlWJwsQap2VX5pwzwo4h3eOamfo= github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY= github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY= github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k= diff --git a/lockserver.defaults.json b/lockserver.defaults.json index 2af78c2..02b3712 100644 --- a/lockserver.defaults.json +++ b/lockserver.defaults.json @@ -1,6 +1,5 @@ { "zwave-js-server": "ws://home-assistant:3000", "sqlite-database": "lockserver.db", - "http-bind": ":8080", - "session-secrets": [] + "http-bind": ":8080" }