Skip to main content

Cache JIRA basic authentication sessions to disk for console apps.

Project description

Do you have command line applications which interact with JIRA servers? Do your users have to enter their credentials every time they run your applications? Are you unable to use OAuth because your command line application is open sourced or you have no way of securing the consumer secret?

Hi, Robpol86 here for jira-context. The easy way to prompt for credentials and cache session cookies on your clients’ workstations.

jira-context is supported on Python 2.6, 2.7, 3.3, and 3.4.

Build Status Coverage Status Latest Version Downloads Download format License

Quickstart

Install:

pip install jira-context

Usage

# example.py
from __future__ import print_function
import sys
from jira_context import JIRA

server = 'https://jira.company.local'
query = 'assignee = currentUser() AND resolution = Unresolved'
if len(sys.argv) == 2:
    JIRA.FORCE_USER = sys.argv[1]

print('Connecting to: ' + server)
with JIRA(server=server) as j:
    if j.ABORTED_BY_USER:
        print('Aborted by user.', file=sys.stderr)
        sys.exit(1)
    issues = j.search_issues(query, maxResults=5)

for issue in issues:
    print(issue.key, issue.fields.summary)
$ python example.py
Connecting to: https://jira.company.local
JIRA username: does_not_exist
JIRA password:
Authentication failed or bad password, try again.
JIRA username:
Aborted by user.
$ python example.py $USER
Connecting to: https://jira.company.local
JIRA password:
FAKE-659 service solahart hp 082113812149
FAKE-620 Need new version to be compatible in Jira 6.3.1
FAKE-525 Half page become blank when Activity Stream gadget view as Wallboard
FAKE-468 create page and with custom fields
FAKE-022 As a burndown gadget I should support GH 6.0+
$ python example.py
Connecting to: https://jira.company.local
FAKE-659 service solahart hp 082113812149
FAKE-620 Need new version to be compatible in Jira 6.3.1
FAKE-525 Half page become blank when Activity Stream gadget view as Wallboard
FAKE-468 create page and with custom fields
FAKE-022 As a burndown gadget I should support GH 6.0+

Class Attributes

Persisted

These attributes/variables are persisted throughout the lifetime of the currently running process. If you’ve got two with blocks and ABORTED_BY_USER becomes True in the first one, the second block will skip authentication.

Name

Description/Notes

ABORTED_BY_USER

False by default. Becomes True if USER_CAN_ABORT is True and the user enters a blank username or password.

COOKIE_CACHE_FILE_PATH

File path to the cache file used to store the base64 encoded session cookie.

FORCE_USER

If set to a string, user won’t be prompted for their username.

USER_CAN_ABORT

Set to False if you don’t want the user to continue without a JIRA session if they enter a blank user/pass.

Instance

These attributes are persisted only in the current JIRA() instance.

Name

Description/Notes

prompt_for_credentials

Instantiate with False if you don’t want the user prompted for credentials (useful in threads).

authentication_failed

Becomes True if prompt_for_credentials is False and cached cookies were invalid/missing.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jira-context-1.0.0.tar.gz (7.0 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page