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

VSCODE-1050: Add Bearer Auth using PAT for hosted BitBucket (as done for hosted Jira) #22

Conversation

bernhardkaindl
Copy link

@bernhardkaindl bernhardkaindl commented Dec 11, 2024

Like the API of Jira and Bitbucket, the API of Bitbucket supports Bearer Auth using PAT instead of Basic Auth:
https://confluence.atlassian.com/enterprise/using-personal-access-tokens-1026032365.html

A number of other customers have expressed a need for this feature, not just us (Cloud Software Group): We disallow the use of HTTP Basic Auth for security reasons for the Confluence, Jira and Bitbucket APIs of our self-hosted services. Instead, we require the use of Bearer Auth using a PAT by the users.

A background information for this is that, that your security policy requires 2FA or alternatively tokens, password authentication without a 2nd factor as implemented in HTTP Basic Authentication is prohibited by company security policy, and therefore HTTP Basic Authentication is prohibited.

Also, by security policy, passwords have to be changed frequently, so even without that prohibition, password authentication would be very cumbersome as frequent changes result in frequent breakdown of the Atlascode login in VS Code.

Right now, the Atlascloud plugin supports authenticating to Jira using PAT because of a requirement by a customer, but the same has not been extended to Bitbucket, it only supports using username/password (Basic Authentication).

Therfore, we use Personal Access Tokens with Bearer authentication. This is an example with curl as client:

curl -v --oauth2-bearer $PAT https:///rest/api/1.0/users/userslug?avatarSize=48

Bearer Authorization is already available in atlascode, but not yet enabled for Bitbucket, it just was requested for Jira and not for Bitbucket:
https://bitbucket.org/atlassianlabs/atlascode/issues/237/allow-saml-sso-as-authentication-method

All that remains for Atlascode is to allow Bearer Authorization for Bitbucket as well.

This is what this PR does. It adds the same option to alternatively use PAT auth for self-hosted Bitbucket like the Jira client of Atlascode already implements.

This is a transfer of my original PR from BitBucket to Github:
https://bitbucket.org/atlassianlabs/atlascode/pull-requests/1050/bitbucket-add-support-for-login-by-api
https://bitbucket.org/atlassianlabs/atlascode/issues/820/allow-authentication-method-pat-personal
Users that approved or wanted this PR as well: Jeff Byrnes, Sham Garud, Mark Turner, Vladyslav Zuiev, Remy Even

Copy link

Thank you for your submission! Like many open source projects, we ask that you sign our CLA (Contributor License Agreement) before we can accept your contribution.
If your email is listed below, please ensure that you sign the CLA with the same email address.

The following users still need to sign our CLA:
❌bernhardkaindl

Already signed the CLA? To re-check, try refreshing the page.

@bernhardkaindl
Copy link
Author

bernhardkaindl commented Dec 11, 2024

For:

The following users still need to sign our CLA:
❌bernhardkaindl

I get this error:

Uh oh!
Unfortunately, there was an error submitting your details.
Are you attempting to update an existing contributor record? If so, please email us with your details.

I already signed the CLA from the original PR https://bitbucket.org/atlassianlabs/atlascode/pull-requests/1050/bitbucket-add-support-for-login-by-api, BTW.

@sdzh-atlassian
Copy link
Member

Hello, thanks for the contribution @bernhardkaindl, and thanks for the review @jeremyfiel!

Sorry that you had to run into an issue with CLA, we're still ironing things out a bit in this repo 😀
I've reached out to our OSS folks, let's see what we can do on our end

@sdzh-atlassian
Copy link
Member

The OSS folks got back to me about the CLA issue :)

Could you please try pushing something into this PR, or just force-pushing to reset the checks?
The CLA check may have had a bug the first time

Again, sorry for the inconvenience :)

@bernhardkaindl
Copy link
Author

@sdzh-atlassian

The OSS folks got back to me about the CLA issue :)

Could you please try pushing something into this PR, or just force-pushing to reset the checks?
The CLA check may have had a bug the first time

Again, sorry for the inconvenience :)

I merged Fix spelling of credentials, but this did not fix the SLA issue.

I even tried another GitHub Username @bkaindl of mine that did not sign the SLA before while keeping the same email address in the e-mail address field of the SLA form, but the error did not change.

I then tried to also change the email address in the SLA form to another email address that is not the email address that already would have signed the SLA, and then, I could sign the SLA as @bkaindl.

But of course, this PR was opened using @bernhardkaindl, so if the OSS folks can't fix the detection that @bernhardkaindl already signed the SLA or alternatively can't be fixed to be able to re-sign the SLA a 2nd time, I'd have to open a new PR using @bkaindl.

Like the API of Jira and Bitbucket, the API of Bitbucket supports Bearer
Auth using PAT instead of Basic Auth:
https://confluence.atlassian.com/enterprise/using-personal-access-tokens-1026032365.html

A number of other customers have expressed a need for this feature, not
just us (Cloud Software Group): We disallow the use of HTTP Basic Auth
for security reasons for the Confluence, Jira and Bitbucket APIs of our
self-hosted services. Instead, we require the use of Bearer Auth using a
PAT by the users.

A background information for this is that, that your security policy
requires 2FA or alternatively tokens, password authentication without a
2nd factor as implemented in HTTP Basic Authentication is prohibited by
company security policy, and therefore HTTP Basic Authentication is
prohibited.

Also, by security policy, passwords have to be changed frequently, so
even without that prohibition, password authentication would be very
cumbersome as frequent changes result in frequent breakdown of the
Atlascode login in VS Code.

Right now, the Atlascloud plugin supports authenticating to Jira using
PAT because of a requirement by a customer, but the same has not been
extended to Bitbucket, it only supports using username/password (Basic
Authentication).

curl -v --oauth2-bearer $PAT https://<self-hosted bitbucket server>/rest/api/1.0/users/userslug?avatarSize=48

Bearer Authorization is already available in atlascode, but not yet
enabled for Bitbucket, it just was requested for Jira and not for
Bitbucket:
https://bitbucket.org/atlassianlabs/atlascode/issues/237/allow-saml-sso-as-authentication-method

All that remains for Atlascode is to allow Bearer Authorization for Bitbucket as well.

This is what this PR does. It adds the same option to alternatively use
PAT auth for self-hosted Bitbucket like the Jira client of Atlascode
already implements.

Signed-off-by: Bernhard Kaindl <bernhard.kaindl@gmx.de>
@bwieger-atlassian-com
Copy link
Collaborator

Closed as it is a duplicate.

Thank you @bernhardkaindl and @bkaindl for raising these PRs!

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.

5 participants