forked from mickael-kerjean/filestash
-
Notifications
You must be signed in to change notification settings - Fork 0
/
constants.go
53 lines (48 loc) · 1.6 KB
/
constants.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package common
import (
"os"
"path/filepath"
)
const (
AppVersion = "v0.5"
LogPath = "data/state/log/"
ConfigPath = "data/state/config/"
DbPath = "data/state/db/"
FtsPath = "data/state/search/"
CertPath = "data/state/certs/"
TmpPath = "data/cache/tmp/"
CookieNameAuth = "auth"
CookieNameProof = "proof"
CookieNameAdmin = "admin"
CookiePathAdmin = "/admin/api/"
CookiePath = "/api/"
FileIndex = "./data/public/index.html"
FileAssets = "./data/public/"
UrlSetup = "/admin/setup"
)
func init() {
cd := GetHomeDir()
os.MkdirAll(filepath.Join(GetHomeDir(), LogPath), os.ModePerm)
os.MkdirAll(filepath.Join(cd, FtsPath), os.ModePerm)
os.MkdirAll(filepath.Join(cd, ConfigPath), os.ModePerm)
os.RemoveAll(filepath.Join(cd, TmpPath))
os.MkdirAll(filepath.Join(cd, TmpPath), os.ModePerm)
}
var (
BuildRef string
BuildDate string
SecretKey string
SecretKeyDerivateForProof string
SecretKeyDerivateForAdmin string
SecretKeyDerivateForUser string
SecretKeyDerivateForHash string
)
// InitSecretDerivate Improve security by calculating derivative of the secret key to restrict the attack surface
// in the worst case scenario with one compromise secret key
func InitSecretDerivate(secret string) {
SecretKey = secret
SecretKeyDerivateForProof = Hash("PROOF_"+SecretKey, len(SecretKey))
SecretKeyDerivateForAdmin = Hash("ADMIN_"+SecretKey, len(SecretKey))
SecretKeyDerivateForUser = Hash("USER_"+SecretKey, len(SecretKey))
SecretKeyDerivateForHash = Hash("HASH_"+SecretKey, len(SecretKey))
}