Antonio Mika
·
2026-10-10
1package auth
2
3import (
4 "log/slog"
5 "strings"
6
7 "github.com/picosh/pico/pkg/shared"
8)
9
10type Config struct {
11 Debug bool
12 DbURL string
13 Issuer string
14 Domain string
15 Port string
16 Secret string
17 SecretWebhook string
18 Logger *slog.Logger
19}
20
21func NewConfig() *Config {
22 debug := shared.GetEnv("AUTH_DEBUG", "0")
23 withPipe := strings.ToLower(shared.GetEnv("PICO_PIPE_ENABLED", "true")) == "true"
24
25 return &Config{
26 DbURL: shared.GetEnv("DATABASE_URL", ""),
27 Debug: debug == "1",
28 Issuer: shared.GetEnv("AUTH_ISSUER", "pico.sh"),
29 Domain: shared.GetEnv("AUTH_DOMAIN", "http://0.0.0.0:3000"),
30 Port: shared.GetEnv("AUTH_WEB_PORT", "3000"),
31 Secret: shared.GetEnv("PICO_SECRET", ""),
32 SecretWebhook: shared.GetEnv("PICO_SECRET_WEBHOOK", ""),
33 Logger: shared.CreateLogger("auth-web", withPipe),
34 }
35}