Skip to content

Commit

Permalink
Bitbucket Server: Send password as Bearer instead of Basic Auth (#2461)
Browse files Browse the repository at this point in the history
* Bitbucket Server: Send password as Bearer instead of Basic Auth

Signed-off-by: Devan Patel <Dev25@users.noreply.github.com>

* docs: Add Bearer note for Bitbucket Server auth

Signed-off-by: Dev <Dev25@users.noreply.github.com>

Signed-off-by: Devan Patel <Dev25@users.noreply.github.com>
Signed-off-by: Dev <Dev25@users.noreply.github.com>
  • Loading branch information
Dev25 authored Oct 31, 2022
1 parent e20a574 commit c03ef1d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions runatlantis.io/docs/access-credentials.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ Since v0.19.7, a new permission for `Administration` has been added. If you have
- Give the token **Read** Project permissions and **Write** Pull request permissions
- Click **Create** and record the access token

NOTE: Atlantis will send the token as a [Bearer Auth to the Bitbucket API](https://confluence.atlassian.com/bitbucketserver/http-access-tokens-939515499.html#HTTPaccesstokens-UsingHTTPaccesstokens) instead of using Basic Auth.

### Azure DevOps
- Create a Personal access token by following [https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=azure-devops](https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=azure-devops)
- Label the password "atlantis"
Expand Down
6 changes: 5 additions & 1 deletion server/events/vcs/bitbucketserver/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,11 @@ func (b *Client) prepRequest(method string, path string, body io.Reader) (*http.
if err != nil {
return nil, err
}
req.SetBasicAuth(b.Username, b.Password)

// Personal access tokens can be sent as basic auth or bearer
bearer := "Bearer " + b.Password
req.Header.Add("Authorization", bearer)

if body != nil {
req.Header.Add("Content-Type", "application/json")
}
Expand Down

0 comments on commit c03ef1d

Please sign in to comment.