implement password encrpytion in credentials
This commit is contained in:
parent
64149b54fc
commit
4e7d0d778a
2
Pipfile
2
Pipfile
@ -4,11 +4,9 @@ url = "https://pypi.org/simple"
|
|||||||
verify_ssl = true
|
verify_ssl = true
|
||||||
|
|
||||||
[dev-packages]
|
[dev-packages]
|
||||||
pycrypto = "*"
|
|
||||||
fernet = "*"
|
fernet = "*"
|
||||||
|
|
||||||
[packages]
|
[packages]
|
||||||
pycrypto = "*"
|
|
||||||
fernet = "*"
|
fernet = "*"
|
||||||
|
|
||||||
[requires]
|
[requires]
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from password import Password
|
||||||
from pwdfile import Pwdfile
|
from pwdfile import Pwdfile
|
||||||
|
|
||||||
|
|
||||||
@ -11,10 +12,13 @@ class Credentials:
|
|||||||
def read_cred(self, service):
|
def read_cred(self, service):
|
||||||
return self.creds[service]
|
return self.creds[service]
|
||||||
|
|
||||||
def create_cred(self, service, username, password):
|
def create_cred(self, service, username, password=None):
|
||||||
|
if password is None:
|
||||||
|
password = Password.generate(mn=64)
|
||||||
|
|
||||||
new_entry = {
|
new_entry = {
|
||||||
"username": username,
|
"username": username,
|
||||||
"password": password
|
"password": Password().encrypt(password)
|
||||||
}
|
}
|
||||||
self.creds[service] = new_entry
|
self.creds[service] = new_entry
|
||||||
Pwdfile().write(self.creds)
|
Pwdfile().write(self.creds)
|
||||||
@ -24,7 +28,7 @@ class Credentials:
|
|||||||
if username is None and password is not None:
|
if username is None and password is not None:
|
||||||
self.creds[service] = {
|
self.creds[service] = {
|
||||||
"username": current_entry["username"],
|
"username": current_entry["username"],
|
||||||
"password": password
|
"password": Password().encrypt(password)
|
||||||
}
|
}
|
||||||
elif username is not None and password is None:
|
elif username is not None and password is None:
|
||||||
self.creds[service] = {
|
self.creds[service] = {
|
||||||
|
Loading…
Reference in New Issue
Block a user