From 56ad1bd77cd656f7f50cc4535aef168c1eb67959 Mon Sep 17 00:00:00 2001 From: Manas Date: May 24 2019 17:45:44 +0000 Subject: Revert "test ini and keyring support" This reverts commit 602260b3d4b18d5b1ee466555485e72d93b28023. --- diff --git a/auth/__pycache__/__init__.cpython-36.pyc b/auth/__pycache__/__init__.cpython-36.pyc deleted file mode 100644 index e54dd9f..0000000 Binary files a/auth/__pycache__/__init__.cpython-36.pyc and /dev/null differ diff --git a/auth/__pycache__/taiga.cpython-36.pyc b/auth/__pycache__/taiga.cpython-36.pyc deleted file mode 100644 index e800c43..0000000 Binary files a/auth/__pycache__/taiga.cpython-36.pyc and /dev/null differ diff --git a/auth/__pycache__/tauth.cpython-36.pyc b/auth/__pycache__/tauth.cpython-36.pyc deleted file mode 100644 index c7f18ab..0000000 Binary files a/auth/__pycache__/tauth.cpython-36.pyc and /dev/null differ diff --git a/auth/pauth.py b/auth/pauth.py deleted file mode 100644 index e69de29..0000000 --- a/auth/pauth.py +++ /dev/null diff --git a/auth/tauth.py b/auth/tauth.py deleted file mode 100644 index 99f156d..0000000 --- a/auth/tauth.py +++ /dev/null @@ -1,73 +0,0 @@ -import requests -import json -import keyring -import random -import os -import binascii -import getpass -import configparser - -config = configparser.ConfigParser() -confi.read('config.ini') - -service_id = config['TAIGA']['SERVICE_ID'] # service id -service_token = config['TAIGA']['SERVICE_TOKEN'] # service d for auth - - -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) - payload = { - 'type': 'normal', - 'username': username, - 'password': keyring.get_password(service_id, username) - } - # print(payload) # only for debugging - - try: - r = requests.post( - "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) - - -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: - # keyring.set_password("taiga", username) - keyring.set_password(service_id, "username", username) - 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") diff --git a/config.ini b/config.ini deleted file mode 100644 index b3e5d51..0000000 --- a/config.ini +++ /dev/null @@ -1,10 +0,0 @@ -[TAIGA] -SERVICE_ID = taiga -SERVICE_TOKEN = taiga_auth -PID = 315827 # for test only - - -[PAGURE] -SERVICE_ID = pagure - -[BUGZILLA] \ No newline at end of file diff --git a/convert.py b/convert.py deleted file mode 100644 index 517e29a..0000000 --- a/convert.py +++ /dev/null @@ -1,78 +0,0 @@ -import os -import requests -import json -import keyring -import configparser - -config = configparser.ConfigParser() -confi.read('config.ini') - -service_id = config['TAIGA']['SERVICE_ID'] # service id -service_token = config['TAIGA']['SERVICE_TOKEN'] -pid = config['TAIGA']['PID'] - -""" -with open('auth.txt', 'r') as a_file: - token = - # auth_t = token.encode("ascii", "ignore") - # print(token) # debug only -""" -keyring.get_password(service_id, username) -headers = { - 'Content-Type': 'application/json', - 'Authorization': 'Bearer {0}'.format(keyring.get_password(service_id, username)) -} - - -def convert(args): - for _, value in args._get_kwargs(): # iteratingover name space object - for x in value: - try: - print(headers) # Debug only - url = "https://api.taiga.io/api/v1/issues/by_ref?ref=" + str(x) + "&project=" + str(pid) - # debugurl = "https://api.taiga.io/api/v1/issues/by_ref" - print(url) # debug/dev env only - # print(debugurl) # Debug only - # ino = str(x) + '/' - """ - params = ( - ('ref', ino), - ('project', str(pid)), - ) - """ - r = requests.get( - url, - # debugurl, - headers=headers, - # params=params - ) - # print("get object",r.json()) # Debug/Dev env only - if r.status_code == 200: - data = json.loads(r.content) - # print(data) - details = data['description'] - subject = data['subject'] - payload = { - 'project': pid, - 'description': details, - 'subject': subject - } - print("post object") - r = requests.post( - 'https://api.taiga.io/api/v1/userstories', - data=json.dumps(payload), - headers=headers - ) - if r.status_code == 200: - print("Sucessfully converted issue: {}".format(x)) - elif r.status_code == 401: - print("Authorization issues try reauthenticating") - except Exception as e: - print(e) - -""" -curl -X GET \ --H "Content-Type: application/json" \ --H "Authorization: Bearer ${eyJ1c2VyX2F1dGhlbnRpY2F0aW9uX2lkIjozNTY4MDR9:1hI6pm:4d4mA-gUXC2S0FxaladX0Fd_3gA}" \ --s https://api.taiga.io/api/v1/issues/by_ref?ref=1\&project=315827 -""" \ No newline at end of file