Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[OJ-12496] Add bearer token authorization for Jira Server #161

Merged
merged 1 commit into from
Oct 19, 2021

Conversation

ametzger
Copy link
Member

@ametzger ametzger commented Oct 18, 2021

In cases where a customer has disabled basic authentication on Jira server (see here) we want to allow using Authorization: Bearer <token> headers directly instead of forcing all users to use basic auth. This is a bit hacky but will allow customers to use bearer tokens in the short term.

Tested this locally against a Jira server running in Docker on which I disabled basic authentication and against the Jellyfish cloud Jira instance, both of which worked.

Patch has also been submitted upstream, so we should use that if/when it is merged.

@ametzger ametzger added the enhancement New feature or request label Oct 18, 2021
@ametzger ametzger self-assigned this Oct 18, 2021
@ametzger ametzger requested a review from a team October 18, 2021 20:56
docs/.ruby-version Outdated Show resolved Hide resolved
jf_agent/main.py Outdated
if config.jira_url and not (jira_username and jira_password):
# This is a bit hairy, they must either provide a jira username
# and a jira password OR a single jira bearer token.
if config.jira_url and ((not (jira_username and jira_password)) and (not jira_bearer_token)):
Copy link
Contributor

@eliwind eliwind Oct 18, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(jira_username and jira_password) != bool(jira_bearer_token) perhaps?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ie one side must be truthy and one falsy

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense but also might be a bit less readable (unless this way is more pythonic?)

Copy link
Member

@sarah256 sarah256 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, just some small comments!


3. Add the following section to your environment variable file. This is the same file mentioned in step 3 above. Adding the following variables allows the agent to access your Jira data:
<p class="code-block"><code>
JIRA_BEARER_TOKEN=...<br/>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit (feel free to ignore) I don't think you need a <br/> here

jf_agent/main.py Outdated
if config.jira_url and not (jira_username and jira_password):
# This is a bit hairy, they must either provide a jira username
# and a jira password OR a single jira bearer token.
if config.jira_url and ((not (jira_username and jira_password)) and (not jira_bearer_token)):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense but also might be a bit less readable (unless this way is more pythonic?)

In cases where a customer has disabled basic authentication on Jira
server (see
[here](https://confluence.atlassian.com/enterprise/disabling-basic-authentication-1044776464.html))
we want to allow using `Authorization: Bearer <token>` headers
directly instead of forcing all users to use basic auth. This is a bit
hacky (I would like to get this integrated upstream, PR for that
coming soon) but will allow customers to use bearer tokens in the
short term.

Tested this locally against a Jira server running in Docker on which I
disabled basic authentication and against the Jellyfish cloud Jira
instance, both of which worked.
@ametzger ametzger force-pushed the oj-12496-bearer-token-auth branch from 37ac4e8 to 9c8afe0 Compare October 19, 2021 16:21
@ametzger ametzger requested review from sarah256 and eliwind October 19, 2021 16:21
Copy link
Contributor

@eliwind eliwind left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

@ametzger ametzger merged commit b00cc65 into master Oct 19, 2021
@ametzger ametzger deleted the oj-12496-bearer-token-auth branch October 19, 2021 20:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants