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

Made Credential param optional to allow for bearer token authentication #439

Merged
merged 4 commits into from
Jun 21, 2023

Conversation

pwshmatt
Copy link

@pwshmatt pwshmatt commented May 30, 2021

Description

Made the Credential parameter optional for the New-JiraSession function. If the Credential parameter is passed, add it to the parameter splat to keep existing functionality.

Motivation and Context

It appears that using Personal Access Tokens (PATs) on Jira Server on-prem is not working as described in the official module documentation. The documentation states that you should be able to pass the email address and PAT into the username and password field respectively. However, this doesn't work in all cases. Removing the mandatory attribute on the Credential parameter for the New-JiraSession function allows us to take advantage of the Header parameter that is already available without the need to pass credentials and use basic authentication. Since the Header parameter is already there and works in New-JiraSession, with this new change we can now pass in custom headers that use the more widely available Bearer token method for authentication to the Jira REST API.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My code follows the code style of this project.
  • I have added Pester Tests that describe what my changes should do.
  • I have updated the documentation accordingly.

@pwshmatt pwshmatt requested review from a team as code owners May 30, 2021 14:33
@lipkau
Copy link
Member

lipkau commented May 30, 2021

Hi matt.
Thanks for the PR.
I don't consider using the -Headers parameter for storing the bearer token into the WebSession that obvious.
I would like you to extend the JiraPS/docs/en-US/about_JiraPS_Authentication.md with a description of how how this can be used and New-JiraSession.md with an example.

@pwshmatt
Copy link
Author

pwshmatt commented Jun 1, 2021

Hi Oliver,

Thanks for taking a look at the pull request. I've made additions to the two documents you listed. Let me know if anything looks off or needs addressed.

@pwshmatt
Copy link
Author

pwshmatt commented Jun 8, 2021

@lipkau Just wanted to check in and see if you had a moment to review my updates to the documentation. Thanks!

@pwshmatt
Copy link
Author

@lipkau Just checking in since it has been a month since your last comment and I wanted to stay on top of this to address any issues you have.

Thanks!

@lipkau lipkau merged commit a7f26c4 into AtlassianPS:master Jun 21, 2023
@icsy7867
Copy link

icsy7867 commented Aug 3, 2023

Not sure, but i am still having trouble.

I have verified that the PAT is working with the API using postman.

However using the example code in the documentation:

$personalAccessToken = "My Token"
$headers = @{ Authorization = "Bearer $($personalAccessToken)" }
Set-JiraConfigServer -Server "https://my.datacenter.server.com"
New-JiraSession -Headers $headers 

I still get prompted for powershell get-credential, and no matter if I use my username/email addres or token for the password it still fails to authenticate.

@pwshmatt
Copy link
Author

Not sure, but i am still having trouble.

I have verified that the PAT is working with the API using postman.

However using the example code in the documentation:

$personalAccessToken = "My Token"
$headers = @{ Authorization = "Bearer $($personalAccessToken)" }
Set-JiraConfigServer -Server "https://my.datacenter.server.com"
New-JiraSession -Headers $headers 

I still get prompted for powershell get-credential, and no matter if I use my username/email addres or token for the password it still fails to authenticate.

The -Credential parameter was made an optional parameter with this PR. @icsy7867 can you make sure you are running the latest version of the JiraPS module?

@pwshmatt pwshmatt deleted the bearer-token-fix branch August 25, 2023 03:19
@lipkau
Copy link
Member

lipkau commented Aug 25, 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants