Keep the admin surface local while serving tiles on the LAN
Binding to 0.0.0.0 used to demand credentials because the admin console and the tile routes shared one listener. That forced a choice between keeping the console off the network and letting other machines fetch tiles. Admin routes are now loopback-only by default: the service can bind 0.0.0.0 so /tiles, /vectors, the catalog and the probes reach the LAN, while /admin and /api/v1/admin answer 403 to anything arriving from another host. Credentials are only required when ADMIN_ALLOW_REMOTE=true actually opens the console up, which is the case worth guarding. Tests cover both sides: a remote admin request is refused, a remote tile request still reaches the token check.
This commit is contained in:
@@ -28,6 +28,7 @@ type Config struct {
|
||||
AdminToken string
|
||||
AdminUser string
|
||||
AdminPassword string
|
||||
AdminAllowRemote bool
|
||||
CORSAllowedOrigins []string
|
||||
TokenDefaultTTL time.Duration
|
||||
|
||||
@@ -50,6 +51,10 @@ func Load() (Config, error) {
|
||||
if err != nil {
|
||||
return Config{}, fmt.Errorf("parse AUTO_SCAN_ON_START: %w", err)
|
||||
}
|
||||
adminAllowRemote, err := boolEnv("ADMIN_ALLOW_REMOTE", false)
|
||||
if err != nil {
|
||||
return Config{}, fmt.Errorf("parse ADMIN_ALLOW_REMOTE: %w", err)
|
||||
}
|
||||
tokenDefaultTTL, err := durationEnv("TOKEN_DEFAULT_TTL", 720*time.Hour)
|
||||
if err != nil {
|
||||
return Config{}, fmt.Errorf("parse TOKEN_DEFAULT_TTL: %w", err)
|
||||
@@ -76,6 +81,7 @@ func Load() (Config, error) {
|
||||
AdminToken: strings.TrimSpace(stringEnv("ADMIN_TOKEN", "")),
|
||||
AdminUser: strings.TrimSpace(stringEnv("ADMIN_USER", "")),
|
||||
AdminPassword: stringEnv("ADMIN_PASSWORD", ""),
|
||||
AdminAllowRemote: adminAllowRemote,
|
||||
CORSAllowedOrigins: listEnv("CORS_ALLOWED_ORIGINS"),
|
||||
TokenDefaultTTL: tokenDefaultTTL,
|
||||
HealthCheckInterval: healthCheckInterval,
|
||||
|
||||
Reference in New Issue
Block a user