diff --git a/src/daemon/secrets.cr b/src/daemon/secrets.cr index cd58801..6e2d82c 100644 --- a/src/daemon/secrets.cr +++ b/src/daemon/secrets.cr @@ -27,6 +27,18 @@ module Secrets end end + # Load secrets from the disk + def self.load_secrets + Dir.glob(Path.new(SECRET_PATH, "*")).each do |funko_dir| + funko = File.basename(funko_dir) + Dir.glob(Path.new(funko_dir, "*")).each do |secret_file| + name = File.basename(secret_file) + value = File.read(secret_file) + SECRETS["#{funko}-#{name}"] = value + end + end + end + # Gets a secret in form {"name": "funko_name-secret_name", "value": "secret_value"} post "/secrets/" do |env| name = env.params.json["name"].as(String) @@ -36,6 +48,10 @@ module Secrets halt env, status_code: 201, response: "Created" end + get "/secrets/" do |env| + halt env, status_code: 200, response: SECRETS.keys.to_json + end + # Deletes a secret from the disk and memory delete "/secrets/:name/" do |env| name = env.params.url["name"] @@ -44,3 +60,5 @@ module Secrets halt env, status_code: 204, response: "Deleted" end end + +Secrets.load_secrets \ No newline at end of file diff --git a/tinyproxy.conf b/tinyproxy.conf index b339991..eeb89e3 100644 --- a/tinyproxy.conf +++ b/tinyproxy.conf @@ -1,6 +1,6 @@ + User nobody Group nogroup - LogLevel Info Port 8888 Listen 0.0.0.0 Timeout 600 @@ -8,4 +8,4 @@ ReverseOnly Yes ReverseMagic Yes ReversePath "/admin/" "http://127.0.0.1:3000/" - ReversePath "/faaso/hello/" "http://hello:3000/" + ReversePath "/faaso/hello/" "http://hello:3000/" \ No newline at end of file