feat(deploy): restrict the public perimeter and resolve the client address
This commit is contained in:
1 parent
e52ffe7bcb
commit
57174dffba
25 files changed
+1224
-25
No files matched your search
@@ -4,6 +4,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net"
|
||||
"net/netip"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -118,6 +119,11 @@ type Config struct {
|
||||
// PasswordHashConcurrency is the number of password hash derivations
|
||||
// that may run at once; further logins and registrations wait.
|
||||
PasswordHashConcurrency int
|
||||
|
||||
// TrustedProxyCIDRs are the reverse proxies in front of the API. The
|
||||
// client address is taken from X-Forwarded-For only through them (see
|
||||
// middleware.ClientIP). Empty trusts no proxy.
|
||||
TrustedProxyCIDRs []netip.Prefix
|
||||
}
|
||||
|
||||
type LookupEnv func(string) (string, bool)
|
||||
@@ -167,6 +173,9 @@ func LoadFromEnv(lookup LookupEnv) (Config, error) {
|
||||
if err := config.loadPasswordHash(lookup); err != nil {
|
||||
return Config{}, err
|
||||
}
|
||||
if err := config.loadTrustedProxies(lookup); err != nil {
|
||||
return Config{}, err
|
||||
}
|
||||
|
||||
var err error
|
||||
config.DatabaseMigrateOnStart, err = boolOrDefault(lookup, "DATABASE_MIGRATE_ON_START", defaultDatabaseMigrateOnStart)
|
||||
|
||||
Reference in new issue
Block a user