From 94ab903a5016e1fe8d0dbcce4659c38749522707 Mon Sep 17 00:00:00 2001 From: Manas Date: Jun 06 2019 18:08:49 +0000 Subject: auth code cleanup --- diff --git a/auth/bugzilla_auth.py b/auth/bugzilla_auth.py index 61d1e74..ae5603c 100644 --- a/auth/bugzilla_auth.py +++ b/auth/bugzilla_auth.py @@ -16,50 +16,12 @@ bz_url = config['BUGZILLA']['DEFAULT_BUGZILLA_URL'] # taiga server note custom_bz = config['BUGZILLA']['CUSTOM_BUGZILLA_URL'] """ -def refresh_token(): - headers = { - 'Content-Type': 'application/json' - } - - - Used only for testing and Demo - Encrypted Config file/Application token - used in production. - Doing the follwoing in prod is security risk. - - username = keyring.get_password(service_id, "username") - # print(username) # debug only - payload = { - 'type': 'normal', - 'username': username, - 'password': keyring.get_password(service_id, username) - } - # print(payload) # only for debugging - - try: - r = requests.post( - str(taiga_url) + "https://api.taiga.io/api/v1/auth", - data=json.dumps(payload), - headers=headers) - print(r.status_code) - if r.status_code == 200: - - with open('auth.txt', 'w') as a_file: - a_file.write(r.json()['auth_token']) - - try: - keyring.set_password(service_token, "username", r.json()['auth_token']) - print("succesful authentication") - except (keyring.errors.PasswordSetError, Exception) as e: - print("Failed to set auth token") - elif r.status_code == 400: - print("auth error") - except Exception as e: - print(e) - +bugzilla uses a api key to enable the api acess +Currently there is a xml-rpc method to acess +That method is going to be deprecated soon +Thus the latest method uses API key to acess +the api token.is sued by the modern rest api """ - - def reset(): print("You User Id and password will be securly store in the Keyring") username = input("Enter your user id for bugzilla: ") diff --git a/auth/email_auth.py b/auth/email_auth.py index 3b4a9a7..edbfa6b 100644 --- a/auth/email_auth.py +++ b/auth/email_auth.py @@ -3,22 +3,10 @@ def reset(): username = input("Enter your id: ") password = getpass.getpass("Enter your password for taiga: ") try: - # keyring.set_password("taiga", username) - """ - So a workaround to store username along with pass is being used - the only drawback ofthis work around is in the gui keyring broswer - a seperate username keyring will show,sadly this cannot be avoided - at the point of writing this peice of software - """ - """ - The above comment is not true - """ keyring.set_password(service_id, "email_username", username) # refer line 67 keyring.set_password(service_id, username, str(password)) username = binascii.hexlify(os.urandom(20)) # randomising username to avoid sneak memory attacks password = binascii.hexlify(os.urandom(20)) # ranomising pass to avoid sneak memory attacks - # username = random.choices(string.ascii_uppercase + string.digits, k=random.randint(1,10)) - # passwd = random.choices(string.ascii_uppercase + string.digits, k=random.randint(1,10)) print("Password reset succesfully") except (keyring.errors.PasswordSetError, Exception) as e: print("Failed to reset password", e) diff --git a/auth/pagure_auth.py b/auth/pagure_auth.py index 0f36322..dfe3ebb 100644 --- a/auth/pagure_auth.py +++ b/auth/pagure_auth.py @@ -11,14 +11,6 @@ config = configparser.ConfigParser() config.read('config.ini') -""" -def refresh_token(): - headers = { - 'Content-Type': 'application/json' - } -""" - - def reset(): print("Your auth token will be securly store in the Keyring") # username = input("Enter your user id for taiga: ") diff --git a/auth/taiga_auth.py b/auth/taiga_auth.py index e9ffc7c..f046771 100644 --- a/auth/taiga_auth.py +++ b/auth/taiga_auth.py @@ -15,7 +15,7 @@ service_id = config['TAIGA']['SERVICE_ID'] # service id service_token = config['TAIGA']['SERVICE_TOKEN'] # service d for auth # taiga_url = config['TAIGA']['DEFAULT_TAIGA_URL'] # taiga server note # custom_taiga = config['TAIGA']['CUSTOM_TAIGA_URL'] -pid = config['TAIGA']['PID'] +project_id = config['TAIGA']['PROJECT_ID'] if config['TAIGA']['TEST'] == 'yes': taiga_url = config['TAIGA']['CUSTOM_TAIGA_URL'] elif config['TAIGA']['TEST'] == 'no': @@ -72,7 +72,6 @@ def reset(): username = input("Enter your user id for taiga: ") password = getpass.getpass("Enter your password for taiga: ") try: - # keyring.set_password("taiga", username) """ So a workaround to store username along with pass is being used the only drawback ofthis work around is in the gui keyring broswer @@ -86,9 +85,7 @@ def reset(): keyring.set_password(service_id, username, str(password)) username = binascii.hexlify(os.urandom(20)) # randomising username to avoid sneak memory attacks password = binascii.hexlify(os.urandom(20)) # ranomising pass to avoid sneak memory attacks - # username = random.choices(string.ascii_uppercase + string.digits, k=random.randint(1,10)) - # passwd = random.choices(string.ascii_uppercase + string.digits, k=random.randint(1,10)) print("Password reset succesfully") except (keyring.errors.PasswordSetError, Exception) as e: print("Failed to reset password") - # print(e + "Contact the developers asap") +