no listing without apikey
All checks were successful
Build and Publish / BuildAndDeploy (push) Successful in 39s
All checks were successful
Build and Publish / BuildAndDeploy (push) Successful in 39s
This commit is contained in:
@@ -66,6 +66,8 @@ spec:
|
|||||||
fieldPath: status.podIP
|
fieldPath: status.podIP
|
||||||
- name: AMQP_URL
|
- name: AMQP_URL
|
||||||
value: "amqp://admin:12bananer@rabbitmq:5672/"
|
value: "amqp://admin:12bananer@rabbitmq:5672/"
|
||||||
|
- name: API_KEY
|
||||||
|
value: "ApiKey: randomslask2000"
|
||||||
- name: POD_NAME
|
- name: POD_NAME
|
||||||
valueFrom:
|
valueFrom:
|
||||||
fieldRef:
|
fieldRef:
|
||||||
9
main.go
9
main.go
@@ -158,7 +158,7 @@ func main() {
|
|||||||
mux := http.NewServeMux()
|
mux := http.NewServeMux()
|
||||||
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||||
pth, fileName := GetPathAndFileFromUrl(r.URL)
|
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)
|
folder, err := app.GetOrSpawn(pth)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -167,8 +167,12 @@ func main() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
log.Printf("Retrieved folder: %+v, exists: %v", folder)
|
|
||||||
if fileName == "" {
|
if fileName == "" {
|
||||||
|
authKey := r.Header.Get("Authorization")
|
||||||
|
if authKey != apiKey {
|
||||||
|
w.WriteHeader(http.StatusUnauthorized)
|
||||||
|
return
|
||||||
|
}
|
||||||
content, err := folder.Storage.List("")
|
content, err := folder.Storage.List("")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
@@ -200,6 +204,7 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
w.Write([]byte(err.Error()))
|
w.Write([]byte(err.Error()))
|
||||||
|
return
|
||||||
}
|
}
|
||||||
folder.Storage.Put(fileName, data)
|
folder.Storage.Put(fileName, data)
|
||||||
w.WriteHeader(http.StatusCreated)
|
w.WriteHeader(http.StatusCreated)
|
||||||
|
|||||||
Reference in New Issue
Block a user