diff options
author | Max Magorsch <arzano@gentoo.org> | 2020-04-20 01:14:36 +0200 |
---|---|---|
committer | Max Magorsch <arzano@gentoo.org> | 2020-04-20 01:14:36 +0200 |
commit | 338624f0c16757fea7f3bcad48aa6954c27bc8e5 (patch) | |
tree | 0bd4b51587c5bb5eee1a7dcb62bd84ac68b44af6 | |
parent | Fix the initial startup (diff) | |
download | glsamaker-338624f0c16757fea7f3bcad48aa6954c27bc8e5.tar.gz glsamaker-338624f0c16757fea7f3bcad48aa6954c27bc8e5.tar.bz2 glsamaker-338624f0c16757fea7f3bcad48aa6954c27bc8e5.zip |
Make the domain configurable
Signed-off-by: Max Magorsch <arzano@gentoo.org>
-rw-r--r-- | docker-compose.yml | 1 | ||||
-rw-r--r-- | pkg/app/handler/authentication/auth_session/authsession.go | 3 | ||||
-rw-r--r-- | pkg/app/handler/authentication/totp/totp.go | 3 | ||||
-rw-r--r-- | pkg/app/handler/authentication/webauthn/login.go | 5 | ||||
-rw-r--r-- | pkg/config/config.go | 6 |
5 files changed, 14 insertions, 4 deletions
diff --git a/docker-compose.yml b/docker-compose.yml index 4fbd859..604f470 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -14,6 +14,7 @@ services: restart: always environment: GLSAMAKER_LOG_FILE: '/var/log/glsamaker/web.log' + GLSAMAKER_DOMAIN: ${GLSAMAKER_DOMAIN:-localhost} GLSAMAKER_POSTGRES_PASS: ${GLSAMAKER_POSTGRES_PASS:-root} command: "/go/src/glsamaker/bin/glsamaker --serve" depends_on: diff --git a/pkg/app/handler/authentication/auth_session/authsession.go b/pkg/app/handler/authentication/auth_session/authsession.go index c86ca99..f365012 100644 --- a/pkg/app/handler/authentication/auth_session/authsession.go +++ b/pkg/app/handler/authentication/auth_session/authsession.go @@ -1,6 +1,7 @@ package auth_session import ( + "glsamaker/pkg/config" "glsamaker/pkg/database/connection" "glsamaker/pkg/logger" "glsamaker/pkg/models" @@ -52,7 +53,7 @@ func createSessionCookie(w http.ResponseWriter, sessionID string) { ck := http.Cookie{ Name: "session", - Domain: "localhost", + Domain: config.Domain(), Path: "/", Expires: expires, } diff --git a/pkg/app/handler/authentication/totp/totp.go b/pkg/app/handler/authentication/totp/totp.go index 00e6b83..bc1e509 100644 --- a/pkg/app/handler/authentication/totp/totp.go +++ b/pkg/app/handler/authentication/totp/totp.go @@ -3,6 +3,7 @@ package totp import ( "glsamaker/pkg/app/handler/authentication/auth_session" "glsamaker/pkg/app/handler/authentication/utils" + "glsamaker/pkg/config" "glsamaker/pkg/models/users" "bytes" "encoding/base64" @@ -38,7 +39,7 @@ func GetToken(user *users.User) string { func Generate(email string) (string, string) { key, _ := totp.Generate(totp.GenerateOpts{ - Issuer: "glsamakertest.gentoo.org", + Issuer: config.Domain(), AccountName: email, }) diff --git a/pkg/app/handler/authentication/webauthn/login.go b/pkg/app/handler/authentication/webauthn/login.go index 7bf9c1d..d729a55 100644 --- a/pkg/app/handler/authentication/webauthn/login.go +++ b/pkg/app/handler/authentication/webauthn/login.go @@ -7,6 +7,7 @@ import ( "fmt" "github.com/duo-labs/webauthn.io/session" webauthn_lib "github.com/duo-labs/webauthn/webauthn" + "glsamaker/pkg/config" "log" "net/http" ) @@ -101,8 +102,8 @@ func CreateWebAuthn() { if WebAuthn == nil { authn, _ := webauthn_lib.New(&webauthn_lib.Config{ RPDisplayName: "Gentoo GLSAMaker", // Display Name for your site - RPID: "glsamakertest.gentoo.org", // Generally the domain name for your site - RPOrigin: "https://glsamakertest.gentoo.org", // The origin URL for WebAuthn requests + RPID: config.Domain(), // Generally the domain name for your site + RPOrigin: "https://" + config.Domain(), // The origin URL for WebAuthn requests RPIcon: "https://assets.gentoo.org/tyrian/site-logo.png", // Optional icon URL for your site }) diff --git a/pkg/config/config.go b/pkg/config/config.go index bab084d..bcaa981 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -2,6 +2,12 @@ package config import "os" + + +func Domain() string { + return getEnv("GLSAMAKER_DOMAIN", "localhost") +} + func PostgresUser() string { return getEnv("GLSAMAKER_POSTGRES_USER", "root") } |