-
Notifications
You must be signed in to change notification settings - Fork 15
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
Conversation
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)): |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?)
There was a problem hiding this 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/> |
There was a problem hiding this comment.
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)): |
There was a problem hiding this comment.
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.
37ac4e8
to
9c8afe0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm!
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.