Coder Social home page Coder Social logo

jira-tools's Introduction

Jira Oauth Dance

Inspired by an ex-employer, a set of examples to talk to jira.

While this code will probably work, it should be considered PoC code.

Config Files

It uses a json config file in /etc/jira-tools.json to store the shared jira credentials. This allows the shared credentials to be managed by existing host management tools.

See jira-tools.json for an example

Setup Secrets

You'll need a made up secret, and an RSA key. These will be used to authenticate the application (this script) to the jira server. The are insufficient for authorization, and inherently need to be shared with all users of this application.

openssl rand -base64 32 -out shared-secret.txt

openssl genrsa -out jira.key 2048
openssl rsa -pubout -in jira.key -out jira.crt

make-json.py | jq . > jira-tools.json

Configure Jira

You'll need to configure a new application link in jira. This should be found at https:///plugins/servlet/applinks/listApplicationLinks

Create New Link:

  • URL: (The URL doesn't matter, and you can skip the error/warning by clicking continue.

Link Applications:

  • Application Name: Arbitary
  • Application Type: Generic Application
  • Create incoming link: checked.
  • Leave all other options left blank.

Next Popup will be the incoming link:

  • Consumer Key: Shared secret from earlier
  • Consumer Name: Arbitrary
  • Public Key: The RSA keypair previously generated
  • Consumer Callback URL: https://YOUR_AUTH0_DOMAIN/login/callback

Use

As a demo:

python jira-oauth-dance.py
cat ~/.jira-credentials.json
python get-ticket.py TIK-1 TIK-2

A note about oauth

There are many flavors of oauth. As of 2018-Q1, I think jira only supports oauth1. Not oauth2. Not OIDC. This you might need to find older libraries or examples for how to make it go.

ToDo

Some things that would make this more production oriented.

  • Port to golang, Distributing python code is hard
  • Don't write secrets to disk, use the keychain
  • Figure out how to renew credentials, and not just issue new ones

References

https://developer.atlassian.com/server/jira/platform/oauth/

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.