From f67c72e86f7603a2b5fe8a00b89cc3f3bab40b8b Mon Sep 17 00:00:00 2001 From: Manas Date: Jun 15 2019 07:22:23 +0000 Subject: files divided as per functionality --- diff --git a/announce/mailing_list.py b/announce/mailing_list.py deleted file mode 100644 index bbc951c..0000000 --- a/announce/mailing_list.py +++ /dev/null @@ -1,42 +0,0 @@ -import smtplib -import ssl -import confifparser -import json -import keyring -import tga -import email.minie.multipart - -service_id = config['EMAIL']['SERVICE_ID'] # service id -# service_token = config['']['SERVICE_TOKEN'] -#pid = config['TAIGA']['PID'] -if config['EMAIL']['TEST'] == 'yes': - sender = config['EMAIL']['CUSTOM_EMAIL_ID'] - reciver = config['EMAIL']['TEST_LIST'] -elif config['EMAIL']['TEST'] == 'no': - sender = config['EMAIL']['DEFAULT_EMAIL_ID] - receiver = config['EMAIL']['LIST'] -else: - print("please set proper test status in config") - - -def email_send(issueno): - port = config['EMAIL']['PORT'] # For SSL - smtp_server = config['EMAIL']['SMTP_SERVER'] - sender_email = sender # Enter your address - receiver_email = reciver # Enter receiver address - data = tga.userstory.get(issueno) - - try: - msg = email.mime.multipart.MIMEMultipart() - msg['to'] = reciver - msg['from'] = sender - msg['subject'] = data['subject'] - msg.add_header('reply-to', reciver_email[0]) - - msg.attach(MIMEText(body, data['description'])) - # This message is sent from Python.""" - - context = ssl.create_default_context() - with smtplib.SMTP_SSL(smtp_server, port, context=context) as server: - server.login(sender_email, password) - server.sendmail(sender_email, receiver_email, message) \ No newline at end of file diff --git a/auth/bugzilla_auth.py b/auth/bugzilla_auth.py deleted file mode 100644 index ae5603c..0000000 --- a/auth/bugzilla_auth.py +++ /dev/null @@ -1,41 +0,0 @@ -import requests -import json -import keyring -import random -import os -import binascii -import getpass -import configparser - -config = configparser.ConfigParser() -config.read('config.ini') - -service_id = config['BUGZILLA']['SERVICE_ID'] # service id -service_token = config['BUGZILLA']['SERVICE_TOKEN'] # service d for auth -bz_url = config['BUGZILLA']['DEFAULT_BUGZILLA_URL'] # taiga server note -custom_bz = config['BUGZILLA']['CUSTOM_BUGZILLA_URL'] - -""" -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: ") - password = getpass.getpass("Enter your password for bugzilla: ") - api_key = getpass.getpass("Enter your bugzilla api: ") - try: - # keyring.set_password("taiga", username) - # keyring.set_password(service_id, "username", username) - keyring.set_password(service_id, username, str(password)) - keyring.set_password(service_id, username, api_key) - 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 and api key reset succesfully") - except (keyring.errors.PasswordSetError, Exception) as e: - print("Failed to reset password & api key", e) diff --git a/auth/email_auth.py b/auth/email_auth.py deleted file mode 100644 index edbfa6b..0000000 --- a/auth/email_auth.py +++ /dev/null @@ -1,12 +0,0 @@ -def reset(): - print("You User Id and password will be securly store in the Keyring") - username = input("Enter your id: ") - password = getpass.getpass("Enter your password for taiga: ") - try: - 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 - 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 deleted file mode 100644 index dfe3ebb..0000000 --- a/auth/pagure_auth.py +++ /dev/null @@ -1,26 +0,0 @@ -import requests -import json -import keyring -import random -import os -import binascii -import getpass -import configparser - -config = configparser.ConfigParser() -config.read('config.ini') - - -def reset(): - print("Your auth token will be securly store in the Keyring") - # username = input("Enter your user id for taiga: ") - api_token = "api_token" - repo_name = input("Enter the repo name you want to set api key for: ") - token = getpass.getpass("Enter your token for" + ' ' + repo_name + ' ' "repository: ") - try: - # keyring.set_password("taiga", username) - keyring.set_password(repo_name, api_token, token) - print("token reset succesfully") - except (keyring.errors.PasswordSetError, Exception) as e: - print("Failed to reset token") - # print(e + "Contact the developers asap") diff --git a/auth/taiga_auth.py b/auth/taiga_auth.py deleted file mode 100644 index f046771..0000000 --- a/auth/taiga_auth.py +++ /dev/null @@ -1,91 +0,0 @@ -import requests -import json -import keyring -import random -import os -import binascii -import getpass -import configparser -import keyring - -config = configparser.ConfigParser() -config.read('config.ini') - -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'] -project_id = config['TAIGA']['PROJECT_ID'] -if config['TAIGA']['TEST'] == 'yes': - taiga_url = config['TAIGA']['CUSTOM_TAIGA_URL'] -elif config['TAIGA']['TEST'] == 'no': - taiga_url = config['TAIGA']['DEFAULT_TAIGA_URL'] -else: - print("please set test status in config") - - -headers = { - 'Content-Type': 'application/json', -} - - -def refresh_token(): - """ - 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, "taiga_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) + "/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, "taiga_token", 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 requests.exceptions.RequestException as e: - print(e) - - -def reset(): - print("You User Id and password will be securly store in the Keyring") - username = input("Enter your user id for taiga: ") - password = getpass.getpass("Enter your password for taiga: ") - try: - """ - 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, "taiga_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 - print("Password reset succesfully") - except (keyring.errors.PasswordSetError, Exception) as e: - print("Failed to reset password") -