mirror of
https://github.com/openfaas/faasd.git
synced 2025-06-19 20:46:40 +00:00
Add check for namespace label openfaas=true
This commit adds the checks that the namespace supplied by the user has the `openfaas=true` label. Without this check the user can deploy/update/read functions in any namespace using the CLI. The UI is not effected because it calls the listnamesaces endpoint, which has the check for the label Signed-off-by: Alistair Hey <alistair@heyal.co.uk>
This commit is contained in:
@ -42,6 +42,18 @@ func MakeDeleteHandler(client *containerd.Client, cni gocni.CNI) func(w http.Res
|
||||
|
||||
lookupNamespace := getRequestNamespace(readNamespaceFromQuery(r))
|
||||
|
||||
// Check if namespace exists, and it has the openfaas label
|
||||
nsValid, err := validateNamespace(client, lookupNamespace)
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
if !nsValid {
|
||||
http.Error(w, "namespace not valid", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
name := req.FunctionName
|
||||
|
||||
function, err := GetFunction(client, name, lookupNamespace)
|
||||
|
Reference in New Issue
Block a user