#!/usr/bin/env python3 """ Common code for handling Jira authentication INITIAL RELEASE: include more common code later """ import os import base64 JIRA_USER = os.environ.get('REPORTER_JIRA_USER', 'githubbot') jirapass = os.environ.get('REPORTER_JIRA_PASSWORD', '') if jirapass == '': with open("/usr/local/etc/tokens/jira.txt", "r", encoding='utf-8') as f: jirapass = f.read().strip() if jirapass == '': raise RuntimeError("Jira password cannot be empty") JIRA_PASS = jirapass def basic_auth(): return base64.encodebytes(('%s:%s' % (JIRA_USER, JIRA_PASS)).encode('ascii')).decode('ascii')[:-1]