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

Basic Bitbucket Server support (login and workspace start) #8086

Merged
merged 1 commit into from
Feb 16, 2022

Conversation

corneliusludmann
Copy link
Contributor

@corneliusludmann corneliusludmann commented Feb 8, 2022

Description

The most recent version of Bitbucket Server (7.20) supports OAuth2 for authentication, we're now able to connect Gitpod with.

This PR enables login and start of plain workspaces for a repository hosted on a Bitbucket Server (version 7.20).

Known limitations and things out of scope here:

  • support for / context of the default branch by default, i.e. no issue/pr context supported
  • broken token validation in the IDE, i.e. it reports missing permissions, though the commits might get pushed
  • no support for projects/webhooks/prebuilds so far
  • no support UI to configure the integration with, i.e. server's config is to be manually adjusted to add an entry for authProviderConfigs

Related Issue(s)

Fixes #7957

How to test

Unfortunately, there is no way to set up the auth provider in the frontend. One needs to patch the server-config configmap in order to get this running in a Gitpod installation. To do so you need to edit the config map:

EDITOR="code --wait" kubectl edit configmap server-config

and add such a configuration:

"authProviderConfigs": [{
    "id": "bitbucketserver",
    "type": "BitbucketServer",
    "host": "bitbucket.gitpod-self-hosted.com",
    "hiddenOnDashboard": false,
    "disallowLogin": false,
    "oauth": {
        "clientId": "<REDACTED>",
        "clientSecret": "<REDACTED>",
        "callBackUrl": "https://clu-bitbucket-server.staging.gitpod-dev.com/auth/bitbucket.gitpod-self-hosted.com/callback",
        "authorizationUrl": "https://bitbucket.gitpod-self-hosted.com/rest/oauth2/latest/authorize",
        "tokenUrl": "https://bitbucket.gitpod-self-hosted.com/rest/oauth2/latest/token",
        "scope": "PUBLIC_REPOS REPO_READ REPO_WRITE REPO_ADMIN PROJECT_ADMIN",
        "scopeSeparator": " "
    }
}]

after that, you'd need to restart the server pods by running:

kubeclt delete pod server-[TAB]

Release Notes

Bitbucket Server: Authorize with Bitbucket Server 7.20 and start workspaces.

@codecov
Copy link

codecov bot commented Feb 8, 2022

Codecov Report

Merging #8086 (8b801f7) into main (30da763) will decrease coverage by 1.13%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #8086      +/-   ##
==========================================
- Coverage   12.31%   11.17%   -1.14%     
==========================================
  Files          20       18       -2     
  Lines        1161      993     -168     
==========================================
- Hits          143      111      -32     
+ Misses       1014      880     -134     
+ Partials        4        2       -2     
Flag Coverage Δ
components-gitpod-cli-app 11.17% <ø> (ø)
components-local-app-app-darwin-amd64 ?
components-local-app-app-darwin-arm64 ?
components-local-app-app-linux-amd64 ?
components-local-app-app-linux-arm64 ?
components-local-app-app-windows-386 ?
components-local-app-app-windows-amd64 ?
components-local-app-app-windows-arm64 ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
components/local-app/pkg/auth/pkce.go
components/local-app/pkg/auth/auth.go

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 30da763...8b801f7. Read the comment docs.

@AlexTugarev AlexTugarev self-assigned this Feb 9, 2022
@AlexTugarev
Copy link
Member

I'm taking over from here. Thanks @corneliusludmann !

@roboquat roboquat added size/XXL and removed size/L labels Feb 9, 2022
@AlexTugarev AlexTugarev force-pushed the clu/bitbucket-server branch 5 times, most recently from ad66981 to ec47e6c Compare February 10, 2022 11:04
@AlexTugarev AlexTugarev changed the title Draft/PoC: Add Bitbucket Server auth provider Basic Bitbucket Server support (login and workspace start) Feb 10, 2022
@AlexTugarev
Copy link
Member

AlexTugarev commented Feb 10, 2022

/werft run with-clean-slate-deployment

👍 started the job as gitpod-build-clu-bitbucket-server.9

@jldec
Copy link
Contributor

jldec commented Feb 11, 2022

I can login using my own bb server credentials 🎉

Screenshot 2022-02-11 at 15 10 44

Screenshot 2022-02-11 at 15 14 24

@jldec
Copy link
Contributor

jldec commented Feb 11, 2022

@jldec
Copy link
Contributor

jldec commented Feb 11, 2022

Copy link
Contributor

@jldec jldec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haven't looked at the code - just tested
I can login, but I can't start a workspace.

@jldec
Copy link
Contributor

jldec commented Feb 11, 2022

@AlexTugarev it would be helpful if you could describe what BB Server context URL shapes are supported now.
(I'm just spending time guessing)

It looks like you got the following to work
https://bitbucket.gitpod-self-hosted.com/projects/JLDEC/repos/test123/browse

But this one does not work
https://bitbucket.gitpod-self-hosted.com/users/jldec/repos/test-repo/browse

@jldec
Copy link
Contributor

jldec commented Feb 15, 2022

/werft run

👍 started the job as gitpod-build-clu-bitbucket-server.11

@jldec
Copy link
Contributor

jldec commented Feb 15, 2022

Hi @AlexTugarev
The build is failing tslint with

src/bitbucket-server/bitbucket-server-repository-provider.ts(13,14): error TS2420: Class 'BitbucketRepositoryProvider' incorrectly implements interface 'RepositoryProvider'.
  Property 'getUserRepos' is missing in type 'BitbucketRepositoryProvider' but required in type 'RepositoryProvider'.
error Command failed with exit code 2.

@AlexTugarev AlexTugarev force-pushed the clu/bitbucket-server branch 3 times, most recently from 7c2fd47 to 88ecf14 Compare February 16, 2022 13:47
@AlexTugarev AlexTugarev marked this pull request as ready for review February 16, 2022 14:06
@AlexTugarev AlexTugarev requested a review from a team February 16, 2022 14:06
@github-actions github-actions bot added the team: webapp Issue belongs to the WebApp team label Feb 16, 2022
@AlexTugarev
Copy link
Member

AlexTugarev commented Feb 16, 2022

/werft run

👍 started the job as gitpod-build-clu-bitbucket-server.16

Copy link
Contributor

@jldec jldec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @AlexTugarev
/LGTM

I am able to

  • authenticate with my BBServer credentials
  • start workspaces for repositories under /users and /projects
  • NOT create projects for BB Server repos (expected)
  • connect integrations for GitLab or GitHub
  • create projects and run workspaces on for GitLab

@roboquat roboquat merged commit e205b48 into main Feb 16, 2022
@roboquat roboquat deleted the clu/bitbucket-server branch February 16, 2022 20:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note size/XXL team: webapp Issue belongs to the WebApp team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

OAuth integration and Workspace starts with Bitbucket Server v7.20
4 participants