mirror of
https://github.com/bvanroll/python-vault-db.git
synced 2025-08-28 19:42:45 +00:00
initial setup of the class
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -127,3 +127,5 @@ dmypy.json
|
|||||||
|
|
||||||
# Pyre type checker
|
# Pyre type checker
|
||||||
.pyre/
|
.pyre/
|
||||||
|
|
||||||
|
.idea
|
@@ -1,6 +1,7 @@
|
|||||||
[build-system]
|
[build-system]
|
||||||
requires = [
|
requires = [
|
||||||
"setuptools>=42",
|
"setuptools>=42",
|
||||||
|
"requests=2.25.1",
|
||||||
"wheel"
|
"wheel"
|
||||||
]
|
]
|
||||||
build-backend = "setuptools.build_meta"
|
build-backend = "setuptools.build_meta"
|
@@ -0,0 +1,30 @@
|
|||||||
|
import requests as rq
|
||||||
|
|
||||||
|
class Database:
|
||||||
|
def __init__(self, dbname, vault_url, token):
|
||||||
|
self.dbname = dbname
|
||||||
|
self.url = vault_url
|
||||||
|
self.valid = False
|
||||||
|
self.lastReq = None #TODO some datetime in here
|
||||||
|
self.ttl = None
|
||||||
|
self.token = token
|
||||||
|
self.username = ""
|
||||||
|
self.password = ""
|
||||||
|
self.get_creds()
|
||||||
|
|
||||||
|
def check_valid(self):
|
||||||
|
#TODO check datetime for current datetime
|
||||||
|
if self.ttl == None:
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
|
def get_creds(self):
|
||||||
|
self.check_valid()
|
||||||
|
if (self.valid):
|
||||||
|
return {"username": self.username, "password": self.password}
|
||||||
|
else:
|
||||||
|
rq.get(url=self.url, headers={"X-Vault-Token":self.token})
|
||||||
|
#TODO set datetime for current datetime
|
||||||
|
#TODO set these to the correct response values
|
||||||
|
self.username = None
|
||||||
|
self.password = None
|
Reference in New Issue
Block a user