From d2ef8b9207a80daa2ba8ffed04147a1c31749027 Mon Sep 17 00:00:00 2001
From: Andrew Cornies <acornies@gmail.com>
Date: Sat, 17 Nov 2018 10:05:20 -0500
Subject: [PATCH] Initial support for secrets in gw: - added SecretHandler type
 - added discussed system/secret endpoint with appropriate http verbs

Signed-off-by: Andrew Cornies <acornies@gmail.com>
---
 gateway/server.go            | 5 +++++
 gateway/types/handler_set.go | 3 +++
 2 files changed, 8 insertions(+)

diff --git a/gateway/server.go b/gateway/server.go
index 69555941..fe97862d 100644
--- a/gateway/server.go
+++ b/gateway/server.go
@@ -89,6 +89,7 @@ func main() {
 	faasHandlers.UpdateFunction = handlers.MakeForwardingProxyHandler(reverseProxy, forwardingNotifiers, urlResolver, nilURLTransformer)
 	faasHandlers.QueryFunction = handlers.MakeForwardingProxyHandler(reverseProxy, forwardingNotifiers, urlResolver, nilURLTransformer)
 	faasHandlers.InfoHandler = handlers.MakeInfoHandler(handlers.MakeForwardingProxyHandler(reverseProxy, forwardingNotifiers, urlResolver, nilURLTransformer))
+	faasHandlers.SecretHandler = handlers.MakeForwardingProxyHandler(reverseProxy, forwardingNotifiers, urlResolver, nilURLTransformer)
 
 	alertHandler := plugin.NewExternalServiceQuery(*config.FunctionsProviderURL, credentials)
 	faasHandlers.Alert = handlers.MakeAlertHandler(alertHandler)
@@ -127,6 +128,8 @@ func main() {
 			auth.DecorateWithBasicAuth(faasHandlers.InfoHandler, credentials)
 		faasHandlers.AsyncReport =
 			auth.DecorateWithBasicAuth(faasHandlers.AsyncReport, credentials)
+		faasHandlers.SecretHandler =
+			auth.DecorateWithBasicAuth(faasHandlers.SecretHandler, credentials)
 	}
 
 	r := mux.NewRouter()
@@ -160,6 +163,8 @@ func main() {
 	r.HandleFunc("/system/functions", faasHandlers.UpdateFunction).Methods(http.MethodPut)
 	r.HandleFunc("/system/scale-function/{name:[-a-zA-Z_0-9]+}", faasHandlers.ScaleFunction).Methods(http.MethodPost)
 
+	r.HandleFunc("/system/secrets", faasHandlers.SecretHandler).Methods(http.MethodGet, http.MethodPut, http.MethodPost)
+
 	if faasHandlers.QueuedProxy != nil {
 		r.HandleFunc("/async-function/{name:[-a-zA-Z_0-9]+}/", faasHandlers.QueuedProxy).Methods(http.MethodPost)
 		r.HandleFunc("/async-function/{name:[-a-zA-Z_0-9]+}", faasHandlers.QueuedProxy).Methods(http.MethodPost)
diff --git a/gateway/types/handler_set.go b/gateway/types/handler_set.go
index 66bfe715..aec47889 100644
--- a/gateway/types/handler_set.go
+++ b/gateway/types/handler_set.go
@@ -26,4 +26,7 @@ type HandlerSet struct {
 
 	// InfoHandler provides version and build info
 	InfoHandler http.HandlerFunc
+
+	// SecretHandler allows secrets to be managed
+	SecretHandler http.HandlerFunc
 }
-- 
GitLab