diff --git a/config.json b/config.json index 70f5a2c..64347a7 100644 --- a/config.json +++ b/config.json @@ -1,5 +1,6 @@ { "api": { + "secret": "CHANGE_YOUR_SECRET_HERE", "database_name": "music.sqlite3", "single_thread": true, "addr": ":8080", diff --git a/pkg/api/api.go b/pkg/api/api.go index f398948..7bd637a 100644 --- a/pkg/api/api.go +++ b/pkg/api/api.go @@ -2,11 +2,10 @@ package api import ( "github.com/gorilla/sessions" - "msw-open-music/pkg/database" "msw-open-music/pkg/commonconfig" + "msw-open-music/pkg/database" "msw-open-music/pkg/tmpfs" "net/http" - "os" ) type API struct { @@ -29,7 +28,7 @@ func NewAPI(config commonconfig.Config) (*API, error) { return nil, err } - store := sessions.NewCookieStore([]byte(os.Getenv("SESSION_KEY"))) + store := sessions.NewCookieStore([]byte(config.APIConfig.SECRET)) mux := http.NewServeMux() apiMux := http.NewServeMux() diff --git a/pkg/commonconfig/config.go b/pkg/commonconfig/config.go index 52ff579..fa29420 100644 --- a/pkg/commonconfig/config.go +++ b/pkg/commonconfig/config.go @@ -11,6 +11,7 @@ type APIConfig struct { Addr string `json:"addr"` FfmpegThreads int64 `json:"ffmpeg_threads"` FfmpegConfigList []FfmpegConfig `json:"ffmpeg_config_list"` + SECRET string `json:"secret"` } type FfmpegConfigList struct {