Option to use truncated signature (#88)

* CircleCI

* Fix docs resize_type -> resizing_type (#91)

As noted in my issue...

* Option to use truncated signature

* Don't use 0 as no-limit for SignatureSize
This commit is contained in:
printercu
2018-11-02 14:10:20 +03:00
committed by Sergey Alexandrovich
parent 7f5f312dfc
commit 7aae98e087
4 changed files with 42 additions and 8 deletions

View File

@@ -135,6 +135,7 @@ type config struct {
Key []byte
Salt []byte
AllowInsecure bool
SignatureSize int
Secret string
@@ -176,6 +177,7 @@ var conf = config{
MaxSrcDimension: 8192,
MaxSrcResolution: 16800000,
AllowInsecure: false,
SignatureSize: 32,
Quality: 80,
GZipCompression: 5,
UserAgent: fmt.Sprintf("imgproxy/%s", version),
@@ -222,6 +224,7 @@ func init() {
hexEnvConfig(&conf.Key, "IMGPROXY_KEY")
hexEnvConfig(&conf.Salt, "IMGPROXY_SALT")
intEnvConfig(&conf.SignatureSize, "IMGPROXY_SIGNATURE_SIZE")
hexFileConfig(&conf.Key, *keyPath)
hexFileConfig(&conf.Salt, *saltPath)
@@ -265,6 +268,9 @@ func init() {
warning("Salt is not defined, so signature checking is disabled")
conf.AllowInsecure = true
}
if conf.SignatureSize < 1 || conf.SignatureSize > 32 {
log.Fatalf("Signature size should be within 1 and 32, now - %d\n", conf.SignatureSize)
}
if len(conf.Bind) == 0 {
log.Fatalln("Bind address is not defined")