llm browser
This commit is contained in:
1 parent
afed023152
commit
a4dbb75195
39 files changed
+3709
-58
No files matched your search
@@ -17,6 +17,8 @@ import (
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"git.k6n.net/mats/fullstack-template/internal/browse"
|
||||
)
|
||||
|
||||
// Config is the validated runtime configuration.
|
||||
@@ -34,6 +36,10 @@ type Config struct {
|
||||
LogFormat string // "json" or "text"
|
||||
// DebugQueries enables Bun query logging (bundebug).
|
||||
DebugQueries bool
|
||||
// FetchUserAgent identifies this server to the sites it inspects.
|
||||
FetchUserAgent string
|
||||
// FetchTimeout bounds each outbound fetch, redirects included.
|
||||
FetchTimeout time.Duration
|
||||
|
||||
// OIDCIssuer is the OpenID Connect issuer; endpoints are discovered,
|
||||
// never hardcoded. Auth is enabled when OIDCClientID is non-empty.
|
||||
@@ -60,6 +66,7 @@ func Load() (Config, error) {
|
||||
AllowedOrigins: splitCSV(env("CORS_ALLOWED_ORIGINS", "http://localhost:5173,http://127.0.0.1:5173")),
|
||||
LogFormat: strings.ToLower(env("LOG_FORMAT", "json")),
|
||||
DebugQueries: env("DB_DEBUG", "false") == "true",
|
||||
FetchUserAgent: env("FETCH_USER_AGENT", browse.DefaultUserAgent),
|
||||
|
||||
OIDCIssuer: strings.TrimRight(env("OIDC_ISSUER", "https://users.k6n.net"), "/"),
|
||||
OIDCClientID: env("OIDC_CLIENT_ID", ""),
|
||||
@@ -72,6 +79,8 @@ func Load() (Config, error) {
|
||||
cfg.AuthSessionTTL = sessionTTL
|
||||
}
|
||||
|
||||
fetchTimeout, fetchTimeoutErr := time.ParseDuration(env("FETCH_TIMEOUT", "15s"))
|
||||
|
||||
var errs []error
|
||||
|
||||
level := strings.ToLower(env("LOG_LEVEL", "info"))
|
||||
@@ -103,6 +112,13 @@ func Load() (Config, error) {
|
||||
} else if cfg.AuthSessionTTL <= 0 {
|
||||
errs = append(errs, errors.New("AUTH_SESSION_TTL must be positive"))
|
||||
}
|
||||
if fetchTimeoutErr != nil {
|
||||
errs = append(errs, fmt.Errorf("invalid FETCH_TIMEOUT: %v", fetchTimeoutErr))
|
||||
} else if fetchTimeout <= 0 {
|
||||
errs = append(errs, errors.New("FETCH_TIMEOUT must be positive"))
|
||||
} else {
|
||||
cfg.FetchTimeout = fetchTimeout
|
||||
}
|
||||
if _, err := url.Parse(cfg.OIDCIssuer); err != nil || !strings.HasPrefix(cfg.OIDCIssuer, "https://") && !strings.HasPrefix(cfg.OIDCIssuer, "http://") {
|
||||
errs = append(errs, fmt.Errorf("invalid OIDC_ISSUER %q (want an http(s) URL)", cfg.OIDCIssuer))
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user