get-hc-secrets 1.5.6__tar.gz → 1.5.8__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {get_hc_secrets-1.5.6 → get_hc_secrets-1.5.8}/PKG-INFO +2 -2
- {get_hc_secrets-1.5.6 → get_hc_secrets-1.5.8}/README.md +1 -1
- {get_hc_secrets-1.5.6 → get_hc_secrets-1.5.8}/pyproject.toml +1 -1
- {get_hc_secrets-1.5.6 → get_hc_secrets-1.5.8}/src/getSecrets/__init__.py +22 -6
- {get_hc_secrets-1.5.6 → get_hc_secrets-1.5.8}/src/get_hc_secrets.egg-info/PKG-INFO +2 -2
- {get_hc_secrets-1.5.6 → get_hc_secrets-1.5.8}/src/get_hc_secrets.egg-info/SOURCES.txt +2 -1
- get_hc_secrets-1.5.8/tests/test_getsecrets.py +24 -0
- {get_hc_secrets-1.5.6 → get_hc_secrets-1.5.8}/LICENSE +0 -0
- {get_hc_secrets-1.5.6 → get_hc_secrets-1.5.8}/setup.cfg +0 -0
- {get_hc_secrets-1.5.6 → get_hc_secrets-1.5.8}/src/get_hc_secrets.egg-info/dependency_links.txt +0 -0
- {get_hc_secrets-1.5.6 → get_hc_secrets-1.5.8}/src/get_hc_secrets.egg-info/requires.txt +0 -0
- {get_hc_secrets-1.5.6 → get_hc_secrets-1.5.8}/src/get_hc_secrets.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: get_hc_secrets
|
|
3
|
-
Version: 1.5.
|
|
3
|
+
Version: 1.5.8
|
|
4
4
|
Summary: A package to read secrets from Hashicorp vault
|
|
5
5
|
Author-email: Xavier Mayeur <xavier@mayeur.be>
|
|
6
6
|
Project-URL: Homepage, https://github.com/xmayeur/getSecrets
|
|
@@ -21,7 +21,7 @@ getSecrets is a simple package that reads from the given engine ('secret' by def
|
|
|
21
21
|
usage:
|
|
22
22
|
|
|
23
23
|
```
|
|
24
|
-
from
|
|
24
|
+
from getSecrets import *
|
|
25
25
|
|
|
26
26
|
data = get_secret(<id>, [<secret>])
|
|
27
27
|
|
|
@@ -3,14 +3,28 @@ from os import getenv
|
|
|
3
3
|
from os.path import join
|
|
4
4
|
import requests
|
|
5
5
|
import yaml
|
|
6
|
+
import os
|
|
7
|
+
import sys
|
|
6
8
|
|
|
7
9
|
|
|
8
|
-
_config_file = "~/.config/.vault/vault.yml"
|
|
9
|
-
_home = getenv("HOME")
|
|
10
|
-
_config = yaml.safe_load(open(join(_home, _config_file.replace("~/", ''))))
|
|
11
10
|
logging.basicConfig(level=logging.INFO, format='%(asctime)s %(message)s',
|
|
12
11
|
datefmt='%m/%d/%Y %I:%M:%S %p')
|
|
13
12
|
|
|
13
|
+
_config_file = "~/.config/.vault/vault.yml"
|
|
14
|
+
_home = getenv("HOME")
|
|
15
|
+
|
|
16
|
+
try:
|
|
17
|
+
_config = yaml.safe_load(open(join(_home, _config_file.replace("~/", ''))))
|
|
18
|
+
except FileNotFoundError:
|
|
19
|
+
if not os.path.exists("/etc/vault"):
|
|
20
|
+
os.makedirs("/etc/vault")
|
|
21
|
+
_home = "/etc/vault"
|
|
22
|
+
try:
|
|
23
|
+
_config = yaml.safe_load(open(join(_home, 'vault.yaml')))
|
|
24
|
+
except FileNotFoundError:
|
|
25
|
+
logging.error(f"No vault configuration found in {_home}")
|
|
26
|
+
sys.exit(1)
|
|
27
|
+
|
|
14
28
|
|
|
15
29
|
def get_secret(id: str, repo: str = 'secret') -> dict:
|
|
16
30
|
"""
|
|
@@ -25,9 +39,12 @@ def get_secret(id: str, repo: str = 'secret') -> dict:
|
|
|
25
39
|
"""
|
|
26
40
|
|
|
27
41
|
base_url = _config['vault']['vault_addr']
|
|
28
|
-
|
|
29
|
-
|
|
42
|
+
if _home == '/etc/vault':
|
|
43
|
+
certs = '/etc/vault/bundle.pem'
|
|
44
|
+
else:
|
|
45
|
+
certs = join(_home, _config['vault']['certs'].replace("~/", ''))
|
|
30
46
|
|
|
47
|
+
token = _config['vault']['token']
|
|
31
48
|
headers = {"X-Vault-Token": token}
|
|
32
49
|
uri = f"/v1/{repo}/data/"
|
|
33
50
|
url = f"{base_url}{uri}{id}"
|
|
@@ -134,4 +151,3 @@ def upd_secret(id: str, data, repo: str = 'secret'):
|
|
|
134
151
|
print(f"http error {resp.status_code}")
|
|
135
152
|
logging.error(f"Vault api error {resp}")
|
|
136
153
|
return None, None
|
|
137
|
-
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: get_hc_secrets
|
|
3
|
-
Version: 1.5.
|
|
3
|
+
Version: 1.5.8
|
|
4
4
|
Summary: A package to read secrets from Hashicorp vault
|
|
5
5
|
Author-email: Xavier Mayeur <xavier@mayeur.be>
|
|
6
6
|
Project-URL: Homepage, https://github.com/xmayeur/getSecrets
|
|
@@ -21,7 +21,7 @@ getSecrets is a simple package that reads from the given engine ('secret' by def
|
|
|
21
21
|
usage:
|
|
22
22
|
|
|
23
23
|
```
|
|
24
|
-
from
|
|
24
|
+
from getSecrets import *
|
|
25
25
|
|
|
26
26
|
data = get_secret(<id>, [<secret>])
|
|
27
27
|
|
|
@@ -6,4 +6,5 @@ src/get_hc_secrets.egg-info/PKG-INFO
|
|
|
6
6
|
src/get_hc_secrets.egg-info/SOURCES.txt
|
|
7
7
|
src/get_hc_secrets.egg-info/dependency_links.txt
|
|
8
8
|
src/get_hc_secrets.egg-info/requires.txt
|
|
9
|
-
src/get_hc_secrets.egg-info/top_level.txt
|
|
9
|
+
src/get_hc_secrets.egg-info/top_level.txt
|
|
10
|
+
tests/test_getsecrets.py
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import secrets
|
|
2
|
+
import unittest
|
|
3
|
+
import getSecrets as gs
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class TestGetSecrets(unittest.TestCase):
|
|
7
|
+
|
|
8
|
+
def test_listsecret(self):
|
|
9
|
+
secrets = gs.list_secret()
|
|
10
|
+
self.assertTrue('test' in secrets)
|
|
11
|
+
|
|
12
|
+
def test_getsecrets(self):
|
|
13
|
+
secret = gs.get_secret('test')
|
|
14
|
+
self.assertTrue('test' in secret)
|
|
15
|
+
self.assertEqual(secret['test'], 'test')
|
|
16
|
+
|
|
17
|
+
def test_usr_pwd(self):
|
|
18
|
+
usr, pwd = gs.get_user_pwd('test')
|
|
19
|
+
self.assertEqual(usr, 'test')
|
|
20
|
+
self.assertEqual(pwd, 'test')
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
if __name__ == '__main__':
|
|
24
|
+
unittest.main()
|
|
File without changes
|
|
File without changes
|
{get_hc_secrets-1.5.6 → get_hc_secrets-1.5.8}/src/get_hc_secrets.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|