Skip to content

Commit

Permalink
Merge branch 'master' of ssh://github.com/mickael-kerjean/filestash
Browse files Browse the repository at this point in the history
  • Loading branch information
mickael-kerjean committed Nov 1, 2023
2 parents e211259 + 3c379d5 commit 87160d7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ git clone https://github.com/mickael-kerjean/filestash
cd filestash
# Install dependencies
npm install # frontend dependencies
npm install --legacy-peer-deps # frontend dependencies
make build_init # install the required static libraries
mkdir -p ./dist/data/state/
cp -R config ./dist/data/state/
Expand Down
7 changes: 7 additions & 0 deletions public/index.backoffice.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,20 @@ <h2>Error: Javascript is off</h2>
PRELOAD("/admin/lib/form.js");
PRELOAD("/admin/components/form.js");
PRELOAD("/admin/components/skeleton.js");
PRELOAD("/admin/pages/adminpage/helper_form.js");
break;
case "/admin/logs":
PRELOAD("/admin/pages/adminpage/ctrl_log.js")
PRELOAD("/admin/model/config.js");
PRELOAD("/admin/lib/random.js");
PRELOAD("/admin/pages/adminpage/helper_form.js");
PRELOAD("/admin/pages/adminpage/model_log.js");
PRELOAD("/admin/pages/adminpage/ctrl_log_form.js");
PRELOAD("/admin/pages/adminpage/ctrl_log_viewer.js");
PRELOAD("/admin/pages/adminpage/ctrl_log_audit.js");
PRELOAD("/admin/lib/form.js");
PRELOAD("/admin/components/form.js");
PRELOAD("/admin/components/skeleton.js");
break;
case "/admin/about":
PRELOAD("/admin/pages/adminpage/ctrl_about.js");
Expand Down
8 changes: 4 additions & 4 deletions server/common/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@ import (

func VerifyApiKey(api_key string) (host string, err error) {
isApiEnabled := Config.Get("features.api.enable").Bool()
apiKey := Config.Get("feature.api.api_key").String()
allowedApiKeys := Config.Get("features.api.api_key").String()

if isApiEnabled == false {
return "", NewError("Api is not enabled", 503)
} else if apiKey == os.Getenv("API_KEY") {
} else if api_key == os.Getenv("API_KEY") {
return "*", nil
}
lines := strings.Split(apiKey, "\n")
lines := strings.Split(allowedApiKeys, "\n")
for _, line := range lines {
line = regexp.MustCompile(` #.*`).ReplaceAllString(line, "") // remove comment
chunks := strings.SplitN(line, " ", 2)
if len(chunks) == 0 {
continue
} else if chunks[0] != apiKey {
} else if chunks[0] != api_key {
continue
}
if len(chunks) == 1 {
Expand Down

0 comments on commit 87160d7

Please sign in to comment.