Skip to content

Instantly share code, notes, and snippets.

@bsquizz
Last active February 7, 2018 22:03
Show Gist options
  • Save bsquizz/119b1c98b8f8670f0768e1d046b602c2 to your computer and use it in GitHub Desktop.
Save bsquizz/119b1c98b8f8670f0768e1d046b602c2 to your computer and use it in GitHub Desktop.
Work-around to get kerberos auth working with python-jira
"""
Requires pykerberos, NOT kerberos!
Make sure you have the right kerb package installed. If 'kerberos' was installed it needs to be
removed and pykerberos re-installed.
"""
from jira import JIRA as JiraClient
class JiraClientOverride(JiraClient):
def _create_kerberos_session(self, *args, **kwargs):
"""
Little hack to get auth cookies from JIRA when using kerberos, otherwise
queries to other URLs hit a 401 and are not handled properly for some
reason
https://stackoverflow.com/questions/21578699/jira-rest-api-and-kerberos-authentication
"""
super(JiraClientOverride, self)._create_kerberos_session(*args, **kwargs)
self._session.get("{}/step-auth-gss".format(self._options['server']))
j = JiraClientOverride("https://myjira.com", kerberos=True, kerberos_options={'mutual_authentication': "DISABLED"})
j.search_issues("assignee = currentUser()")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment