no listing without apikey
All checks were successful
Build and Publish / BuildAndDeploy (push) Successful in 39s

This commit is contained in:
matst80
2025-05-15 19:53:10 +02:00
parent fa47d75541
commit 42c1a8203c
2 changed files with 9 additions and 2 deletions

View File

@@ -66,6 +66,8 @@ spec:
fieldPath: status.podIP
- name: AMQP_URL
value: "amqp://admin:12bananer@rabbitmq:5672/"
- name: API_KEY
value: "ApiKey: randomslask2000"
- name: POD_NAME
valueFrom:
fieldRef:

View File

@@ -158,7 +158,7 @@ func main() {
mux := http.NewServeMux()
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
pth, fileName := GetPathAndFileFromUrl(r.URL)
log.Printf("Request path parts: %+v, fileName:%s", pth, fileName)
log.Printf("Request: %+v, fileName:%s, method: %s", pth, fileName, r.Method)
folder, err := app.GetOrSpawn(pth)
if err != nil {
if err != nil {
@@ -167,8 +167,12 @@ func main() {
return
}
}
log.Printf("Retrieved folder: %+v, exists: %v", folder)
if fileName == "" {
authKey := r.Header.Get("Authorization")
if authKey != apiKey {
w.WriteHeader(http.StatusUnauthorized)
return
}
content, err := folder.Storage.List("")
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
@@ -200,6 +204,7 @@ func main() {
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
w.Write([]byte(err.Error()))
return
}
folder.Storage.Put(fileName, data)
w.WriteHeader(http.StatusCreated)