fix installer
This commit is contained in:
parent
46030a5b14
commit
c2091e746a
19 changed files with 264 additions and 73 deletions
|
|
@ -32,10 +32,11 @@ type Config struct {
|
|||
}
|
||||
|
||||
func Load() (Config, error) {
|
||||
baseURL := strings.TrimRight(env("GO_LOOSE_BASE_URL", "http://localhost:8080"), "/")
|
||||
cfg := Config{
|
||||
Addr: env("GO_LOOSE_ADDR", ":8080"),
|
||||
BaseURL: strings.TrimRight(env("GO_LOOSE_BASE_URL", "http://localhost:8080"), "/"),
|
||||
AuthDomain: strings.TrimPrefix(strings.ToLower(env("GO_LOOSE_AUTH_DOMAIN", "auth.local")), "."),
|
||||
BaseURL: baseURL,
|
||||
AuthDomain: strings.TrimPrefix(strings.ToLower(env("GO_LOOSE_AUTH_DOMAIN", "auth.dev")), "."),
|
||||
DatabaseURL: env("GO_LOOSE_DATABASE_URL", "postgres://goloose:goloose@localhost:5432/goloose?sslmode=disable"),
|
||||
SessionSecret: os.Getenv("GO_LOOSE_SESSION_SECRET"),
|
||||
DevLogin: envBool("GO_LOOSE_DEV_LOGIN", false),
|
||||
|
|
@ -46,7 +47,7 @@ func Load() (Config, error) {
|
|||
OIDCIssuer: strings.TrimRight(os.Getenv("GO_LOOSE_OIDC_ISSUER"), "/"),
|
||||
OIDCClientID: os.Getenv("GO_LOOSE_OIDC_CLIENT_ID"),
|
||||
OIDCClientSecret: os.Getenv("GO_LOOSE_OIDC_CLIENT_SECRET"),
|
||||
OIDCRedirectURL: env("GO_LOOSE_OIDC_REDIRECT_URL", "http://localhost:8080/auth/callback"),
|
||||
OIDCRedirectURL: env("GO_LOOSE_OIDC_REDIRECT_URL", baseURL+"/auth/callback"),
|
||||
AllowedEmailDomains: csv(os.Getenv("GO_LOOSE_ALLOWED_EMAIL_DOMAINS")),
|
||||
AllowPrivateContractURL: envBool("GO_LOOSE_ALLOW_PRIVATE_CONTRACT_URLS", false),
|
||||
BootstrapTenant: env("GO_LOOSE_BOOTSTRAP_TENANT", "default"),
|
||||
|
|
@ -57,7 +58,7 @@ func Load() (Config, error) {
|
|||
return Config{}, errors.New("GO_LOOSE_SESSION_SECRET must contain at least 32 characters")
|
||||
}
|
||||
if cfg.AuthDomain == "" || strings.ContainsAny(cfg.AuthDomain, "/:") {
|
||||
return Config{}, errors.New("GO_LOOSE_AUTH_DOMAIN must be a hostname such as auth.local")
|
||||
return Config{}, errors.New("GO_LOOSE_AUTH_DOMAIN must be a hostname such as auth.dev")
|
||||
}
|
||||
oidcConfigured := cfg.OIDCIssuer != "" && cfg.OIDCClientID != "" && cfg.OIDCClientSecret != ""
|
||||
if cfg.LocalAdminPassword != "" && len(cfg.LocalAdminPassword) < 12 {
|
||||
|
|
|
|||
|
|
@ -43,3 +43,17 @@ func TestLoadAllowsDatabaseLoginWithoutBootstrapAccount(t *testing.T) {
|
|||
t.Fatalf("Load() error = %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadDerivesOIDCRedirectURLFromBaseURL(t *testing.T) {
|
||||
t.Setenv("GO_LOOSE_SESSION_SECRET", "01234567890123456789012345678901")
|
||||
t.Setenv("GO_LOOSE_BASE_URL", "http://auth.dev:18080/")
|
||||
t.Setenv("GO_LOOSE_OIDC_REDIRECT_URL", "")
|
||||
|
||||
cfg, err := Load()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if cfg.OIDCRedirectURL != "http://auth.dev:18080/auth/callback" {
|
||||
t.Fatalf("OIDC redirect URL = %q", cfg.OIDCRedirectURL)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue