Last active
February 11, 2023 19:49
-
-
Save shortstack/e184305bd143c1cb1b2eced24c371459 to your computer and use it in GitHub Desktop.
Store and retrieve secrets from LimaCharlie
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def generate_jwt(): | |
api_key = "" | |
base_url = "https://jwt.limacharlie.io" | |
uid = "" | |
url = "%s?uid=%s&secret=%s" % (base_url, uid, api_key) | |
try: | |
r = requests.get(url) | |
jwt = r.json()["jwt"] | |
return jwt | |
except: | |
return "" | |
def set_secret(oid, secret_key, secret_value): | |
url = "https://api.limacharlie.io/v1/hive/secret/%s/%s/data" % (oid, secret_key) | |
headers = { | |
"Content-Type": "application/json", | |
"Authorization": "Bearer %s" % (generate_jwt()), | |
} | |
params = {"data": '{"secret": "%s"}' % (secret_value)} | |
response = requests.request("POST", url, headers=headers, params=params) | |
return json.loads(response.text) | |
def get_secret(oid, secret_key): | |
url = "https://api.limacharlie.io/v1/hive/secret/%s/%s/data" % (oid, secret_key) | |
headers = { | |
"Content-Type": "application/json", | |
"Authorization": "Bearer %s" % (generate_jwt()), | |
} | |
response = requests.request("GET", url, headers=headers) | |
return json.loads(response.text) | |
def delete_secret(oid, secret_key): | |
url = "https://api.limacharlie.io/v1/hive/secret/%s/%s/data" % (oid, secret_key) | |
headers = { | |
"Content-Type": "application/json", | |
"Authorization": "Bearer %s" % (generate_jwt()), | |
} | |
response = requests.request("DELETE", url, headers=headers) | |
return json.loads(response.text) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment