From 88469fe6a2c490a45a0f55a5170b3ea8613ae18b Mon Sep 17 00:00:00 2001 From: Erikas Date: Fri, 12 Jul 2024 23:57:42 +0300 Subject: [PATCH] Add finishing touches --- cmd/fsmig1/main.go | 11 ----------- config.go | 6 ++++++ docker-compose.yaml | 1 + server.go | 2 +- 4 files changed, 8 insertions(+), 12 deletions(-) delete mode 100644 cmd/fsmig1/main.go diff --git a/cmd/fsmig1/main.go b/cmd/fsmig1/main.go deleted file mode 100644 index 4f2f945..0000000 --- a/cmd/fsmig1/main.go +++ /dev/null @@ -1,11 +0,0 @@ -package main - -import "fmt" - -/* - This app is a migration tool from v0.0.7 to v0.0.8 -*/ - -func main() { - fmt.Println("Hello, World!") -} diff --git a/config.go b/config.go index 30252fc..6e673cf 100644 --- a/config.go +++ b/config.go @@ -14,6 +14,7 @@ type Config struct { DiscordClientID string DiscordClientSecret string DiscordRedirectURL string + SessionSecret string Version bool } @@ -25,6 +26,7 @@ func NewConfig() (*Config, error) { discordClientID := flag.String("discord-client-id", "", "Discord OAuth2 client ID (see https://discord.com/developers/applications)") discordClientSecret := flag.String("discord-client-secret", "", "Discord OAuth2 client secret (see https://discord.com/developers/applications)") discordRedirectURL := flag.String("discord-redirect-url", "", "Discord OAuth2 redirect URL (:///login/callback)") + sessionSecret := flag.String("session-secret", "", "Session secret") flagVersion := flag.Bool("version", false, "prints version of the application") envflag.Parse(envflag.WithPrefix("FS_")) @@ -36,6 +38,7 @@ func NewConfig() (*Config, error) { DiscordClientID: *discordClientID, DiscordClientSecret: *discordClientSecret, DiscordRedirectURL: *discordRedirectURL, + SessionSecret: *sessionSecret, Version: *flagVersion, } @@ -56,6 +59,9 @@ func NewConfig() (*Config, error) { if config.DiscordRedirectURL == "" { return nil, errors.New("missing discord-redirect-url argument") } + if config.SessionSecret == "" { + return nil, errors.New("missing session-secret argument") + } return config, nil } diff --git a/docker-compose.yaml b/docker-compose.yaml index 62fdc46..bc30cc4 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -13,4 +13,5 @@ services: - FS_DISCORD_CLIENT_ID=xxxxxxxxxxxxxxxxxx - FS_DISCORD_CLIENT_SECRET=xxxxxxxxxxxxxxxxxx - FS_DISCORD_REDIRECT_URL=:///login/callback + - FS_SESSION_SECRET=xxxxxxxxxxxxxxxxxx restart: unless-stopped diff --git a/server.go b/server.go index 19a2a66..1afa10b 100644 --- a/server.go +++ b/server.go @@ -66,7 +66,7 @@ func Start(c *Config) { if err != nil { panic(err) } - store := gormsessions.NewStore(db, true, []byte("secret")) + store := gormsessions.NewStore(db, true, []byte(c.SessionSecret)) db.AutoMigrate(&Benchmark{}) // Setup gin //