Skip to content

Instantly share code, notes, and snippets.

@shortstack
Last active February 11, 2023 19:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shortstack/e184305bd143c1cb1b2eced24c371459 to your computer and use it in GitHub Desktop.
Save shortstack/e184305bd143c1cb1b2eced24c371459 to your computer and use it in GitHub Desktop.
Store and retrieve secrets from LimaCharlie
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