Parcourir la source

Disable signature checking if key or salt are not provided

DarthSim il y a 6 ans
Parent
commit
945ffb485b
2 fichiers modifiés avec 9 ajouts et 14 suppressions
  1. 2 2
      README.md
  2. 7 12
      config.go

+ 2 - 2
README.md

@@ -121,8 +121,8 @@ imgproxy is [Twelve-Factor-App](https://12factor.net/)-ready and can be configur
 
 imgproxy requires all URLs to be signed with a key and salt:
 
-* `IMGPROXY_KEY` — (**required**) hex-encoded key;
-* `IMGPROXY_SALT` — (**required**) hex-encoded salt;
+* `IMGPROXY_KEY` — hex-encoded key;
+* `IMGPROXY_SALT` — hex-encoded salt;
 
 You can also specify paths to files with a hex-encoded key and salt (useful in a development environment):
 

+ 7 - 12
config.go

@@ -118,8 +118,6 @@ type config struct {
 	MaxSrcDimension  int
 	MaxSrcResolution int
 
-	AllowInsecure bool
-
 	JpegProgressive bool
 	PngInterlaced   bool
 	Quality         int
@@ -128,8 +126,9 @@ type config struct {
 	EnableWebpDetection bool
 	EnforceWebp         bool
 
-	Key  []byte
-	Salt []byte
+	Key           []byte
+	Salt          []byte
+	AllowInsecure bool
 
 	Secret string
 
@@ -190,8 +189,6 @@ func init() {
 	intEnvConfig(&conf.MaxSrcDimension, "IMGPROXY_MAX_SRC_DIMENSION")
 	megaIntEnvConfig(&conf.MaxSrcResolution, "IMGPROXY_MAX_SRC_RESOLUTION")
 
-	boolEnvConfig(&conf.AllowInsecure, "IMGPROXY_ALLOW_INSECURE")
-
 	boolEnvConfig(&conf.JpegProgressive, "IMGPROXY_JPEG_PROGRESSIVE")
 	boolEnvConfig(&conf.PngInterlaced, "IMGPROXY_PNG_INTERLACED")
 	intEnvConfig(&conf.Quality, "IMGPROXY_QUALITY")
@@ -223,10 +220,12 @@ func init() {
 	presetFileConfig(conf.Presets, *presetsPath)
 
 	if len(conf.Key) == 0 {
-		log.Fatalln("Key is not defined")
+		warning("Key is not defined, so signature checking is disabled")
+		conf.AllowInsecure = true
 	}
 	if len(conf.Salt) == 0 {
-		log.Fatalln("Salt is not defined")
+		warning("Salt is not defined, so signature checking is disabled")
+		conf.AllowInsecure = true
 	}
 
 	if len(conf.Bind) == 0 {
@@ -265,10 +264,6 @@ func init() {
 		log.Fatalf("Max src resolution should be greater than 0, now - %d\n", conf.MaxSrcResolution)
 	}
 
-	if conf.AllowInsecure {
-		warning("Token validation is disabled. Hope you know what you're doing")
-	}
-
 	if conf.Quality <= 0 {
 		log.Fatalf("Quality should be greater than 0, now - %d\n", conf.Quality)
 	} else if conf.Quality > 100 {