minor changes to authenticator
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Torma Kristóf 2021-04-18 16:07:41 +02:00
parent 89b7b68dfe
commit d3e830c59a
Signed by: tormakris
GPG Key ID: DC83C4F2C41B1047
1 changed files with 9 additions and 7 deletions

View File

@ -1,10 +1,12 @@
import os, sys import json
import logging
import os
import shutil
import sys
from base64 import b64encode from base64 import b64encode
from Crypto.Hash import SHA256 from Crypto.Hash import SHA256
from Crypto.Protocol.KDF import bcrypt, bcrypt_check from Crypto.Protocol.KDF import bcrypt, bcrypt_check
import json
import shutil
import logging
auth_logger = logging.getLogger('AUTH APPLICATION ') auth_logger = logging.getLogger('AUTH APPLICATION ')
auth_logger.root.setLevel(logging.INFO) auth_logger.root.setLevel(logging.INFO)
@ -30,7 +32,7 @@ class Authetication:
json.dump(data, outfile) json.dump(data, outfile)
def login(self, username: str, password: str) -> str: def login(self, username: str, password: str) -> str:
with open(Authetication.CONFIG_DIRECTORY_LOCATION + '\\config.txt') as json_file: with open(self.CONFIG_DIRECTORY_LOCATION + '\\config.txt') as json_file:
data = json.load(json_file) data = json.load(json_file)
for user in data['user']: for user in data['user']:
@ -46,7 +48,7 @@ class Authetication:
return user['homeDir'] return user['homeDir']
def checkUserExists(self, username: str) -> bool: def checkUserExists(self, username: str) -> bool:
with open(Authetication.CONFIG_DIRECTORY_LOCATION + '\\config.txt') as json_file: with open(self.CONFIG_DIRECTORY_LOCATION + '\\config.txt') as json_file:
data = json.load(json_file) data = json.load(json_file)
for user in data['user']: for user in data['user']:
@ -67,7 +69,7 @@ class Authetication:
b64pwd = b64encode(SHA256.new(bytePass).digest()) b64pwd = b64encode(SHA256.new(bytePass).digest())
bcrypt_hash = bcrypt(b64pwd, 12) bcrypt_hash = bcrypt(b64pwd, 12)
with open(Authetication.CONFIG_DIRECTORY_LOCATION + '\\config.txt') as json_file: with open(self.CONFIG_DIRECTORY_LOCATION + '\\config.txt') as json_file:
data = json.load(json_file) data = json.load(json_file)
user = { user = {