-
-
Notifications
You must be signed in to change notification settings - Fork 282
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
Jira Bearer Authentication #521
Jira Bearer Authentication #521
Conversation
Hi @rantoniuk, can you please review my code? Thank you in advance! |
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.
Hi!
Thank you for contributing, really great to see this incoming PR. I made some small comments about moving files to better places, but apart from that I think this PR is not yet ready for review:
- the test case is actually not testing anything at the moment. You don't do any assertions and notice in the PR checks menu that the code coverage dropped:
Line: 59.00% (-0.23% against target branch)
- I don't see any changes to config.jelly, so I'm not sure how this new constructor is actually used and how the site should be configured via UI in this case? Maybe the related credentialsId need to be updated as well.
Take a look at:
Hope that helps!
src/main/java/hudson/plugins/jira/authenticationhandler/BearerHttpAuthenticationHandler.java
Outdated
Show resolved
Hide resolved
I updated
|
I updated |
That looks great! I would love you to update everything but that's out of scope for a single PR and would make a mess to review. I propose to do it "in the old way" now and handle the deprecations in another PR when this is merged and you still have power to contribute :) |
Got it 👍 In that case, how do you suggest to proceed? |
Jenkins job stuck 🤔 |
When you feel your change is ready, let me know. Note that you can use the incremental build to do a test run in your sandbox instance to see if it works as expected (link is in the checks panel) |
I was able to test my code on local Jenkins instance and it worked at the first attempt 😎 I tested both bearer token and basic authentication. The only concern I have is that when credentials are unauthorised/bad, I got 401/403 error on Jenkins console but Jenkins jobs succeed anyway. I think that this behaviour is not due to my changes. In the next comment you can see some tests screenshots. I was able to e.g. update Jira ticket workflow both with basic and bearer (Unfortunately, I changed the JiraSite configuration in the second test, without changing job comment 🤣 ). I'll upload further screenshots soon |
@rantoniuk I think that the PR can be merged 👍 I'm confident with the changes and I tested it. Just a note, from the previous screen I changed |
Hi @rantoniuk 😄 Any update on that side? Am I missing something? |
@rantoniuk any update, pls? |
Hi @rantoniuk , any update? |
@EliaBracciSumo sorry for the delay. I'd like to test your changes against our Jira Cloud instance if all looks good. Could you briefly explain how would you configure the plugin after your changes? I took a quick try to test it already by:
Am I missing something? If you wish to try it out against the Jira Cloud instance, let me know and I will create an account for you for tests. |
Bearer credentials with Which versions of the plugin did you install? |
@rantoniuk have you tried to use PAT with |
I didn't because I know PAT method worked before with the Basic auth.
Please try to access https://jenkins-jira-plugin.atlassian.net/ with your Atlassian account, you should be able to request access.
See my previous comment, there is a link to incrementals build (so the version built from this PR). |
@rantoniuk you are right. https://community.atlassian.com/t5/Jira-questions/Jira-on-prem-cloud-API-Personal-Access-Token-PAT/qaq-p/2030384 Jira cloud doesn't allow to create PAT but just API token and this one can be used only with
Since my update works fine with on-premise Jira, maybe I can put a not on the checkbox I added saying Note: Bearer authentication doesn't work with Jira Cloud, use Basic instead. WDYT? |
Yes, that makes sense. I would re-phrase it the other way: "Note: Bearer authentication is only supported in Jira Server, for Jira Cloud leave this unchecked" |
src/test/java/hudson/plugins/jira/auth/JiraRestServiceBearerAuthTest.java
Show resolved
Hide resolved
@rantoniuk thank you for all the support!! In the next days I will proceed (ASAP) with the two pending tasks (repo cleaning and missing apache library) |
Hi team!
The intent of this PR is to allow
JiraRestService
to work with Bearer Token authentication!To do that I implemented new methods and classes:
JiraRestService
constructor that accept bearer token authentication: doing that, I also created private methodbuildBaseApiPath
to avoid to repeat code and make it more readableAuthenticationHandler
class and it will be used as authentication methodJiraConfig
and added bearer auth tests class: added a newtoken
variable inJiraConfig
class and relatedjira.properties
. Added test class to tests implemented codeThis implementation could be a starting point for #497