Secrets are persistent
This commit is contained in:
parent
72c519a23a
commit
02b54ca25d
@ -27,6 +27,18 @@ module Secrets
|
|||||||
end
|
end
|
||||||
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"}
|
# Gets a secret in form {"name": "funko_name-secret_name", "value": "secret_value"}
|
||||||
post "/secrets/" do |env|
|
post "/secrets/" do |env|
|
||||||
name = env.params.json["name"].as(String)
|
name = env.params.json["name"].as(String)
|
||||||
@ -36,6 +48,10 @@ module Secrets
|
|||||||
halt env, status_code: 201, response: "Created"
|
halt env, status_code: 201, response: "Created"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
get "/secrets/" do |env|
|
||||||
|
halt env, status_code: 200, response: SECRETS.keys.to_json
|
||||||
|
end
|
||||||
|
|
||||||
# Deletes a secret from the disk and memory
|
# Deletes a secret from the disk and memory
|
||||||
delete "/secrets/:name/" do |env|
|
delete "/secrets/:name/" do |env|
|
||||||
name = env.params.url["name"]
|
name = env.params.url["name"]
|
||||||
@ -44,3 +60,5 @@ module Secrets
|
|||||||
halt env, status_code: 204, response: "Deleted"
|
halt env, status_code: 204, response: "Deleted"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Secrets.load_secrets
|
@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
User nobody
|
User nobody
|
||||||
Group nogroup
|
Group nogroup
|
||||||
LogLevel Info
|
|
||||||
Port 8888
|
Port 8888
|
||||||
Listen 0.0.0.0
|
Listen 0.0.0.0
|
||||||
Timeout 600
|
Timeout 600
|
||||||
@ -8,4 +8,4 @@
|
|||||||
ReverseOnly Yes
|
ReverseOnly Yes
|
||||||
ReverseMagic Yes
|
ReverseMagic Yes
|
||||||
ReversePath "/admin/" "http://127.0.0.1:3000/"
|
ReversePath "/admin/" "http://127.0.0.1:3000/"
|
||||||
ReversePath "/faaso/hello/" "http://hello:3000/"
|
ReversePath "/faaso/hello/" "http://hello:3000/"
|
Loading…
Reference in New Issue
Block a user