Connect Bitbucket Server with OAuth 1.0
To enable users to work with a remote Git repository that is hosted on a Bitbucket Server:
-
Set up an application link (OAuth 1.0) on the Bitbucket Server.
-
Apply an application link Secret for the Bitbucket Server.
Create an OAuth 1.0 application link on the Bitbucket Server
Create an OAuth 1.0 application link on the Bitbucket Server so that Che can authenticate your developers and provide credential-free access to Bitbucket Server repositories.
-
You are logged in to the Bitbucket Server.
-
opensslis installed in the operating system you are using.
-
On a command line, run the commands to create the necessary files for the next steps and for use when applying the application link Secret:
$ openssl genrsa -out private.pem 2048 && \ openssl pkcs8 -topk8 -inform pem -outform pem -nocrypt -in private.pem -out privatepkcs8.pem && \ cat privatepkcs8.pem | sed 's/-----BEGIN PRIVATE KEY-----//g' | sed 's/-----END PRIVATE KEY-----//g' | tr -d '\n' > privatepkcs8-stripped.pem && \ openssl rsa -in private.pem -pubout > public.pub && \ cat public.pub | sed 's/-----BEGIN PUBLIC KEY-----//g' | sed 's/-----END PUBLIC KEY-----//g' | tr -d '\n' > public-stripped.pub && \ openssl rand -base64 24 > bitbucket-consumer-key && \ openssl rand -base64 24 > bitbucket-shared-secret
-
Go to .
-
Enter
https://<che_fqdn>/into the URL field and click Create new link. -
Under The supplied Application URL has redirected once, check the Use this URL checkbox and click Continue.
-
Enter Che as the Application Name.
-
Select Generic Application as the Application Type.
-
Enter Che as the Service Provider Name.
-
Paste the content of the
bitbucket-consumer-keyfile as the Consumer key. -
Paste the content of the
bitbucket-shared-secretfile as the Shared secret. -
Enter
<bitbucket_server_url>/plugins/servlet/oauth/request-tokenas the Request Token URL. -
Enter
<bitbucket_server_url>/plugins/servlet/oauth/access-tokenas the Access token URL. -
Enter
<bitbucket_server_url>/plugins/servlet/oauth/authorizeas the Authorize URL. -
Check the Create incoming link checkbox and click Continue.
-
Paste the content of the
bitbucket-consumer-keyfile as the Consumer Key. -
Enter Che as the Consumer name.
-
Paste the content of the
public-stripped.pubfile as the Public Key and click Continue.
Connect Che to your Bitbucket Server OAuth 1.0 application
Connect Che to your Bitbucket Server OAuth 1.0 application so that developers can access Bitbucket Server repositories from workspaces without re-entering credentials.
-
You have configured the application link on the Bitbucket Server.
-
You have the following files, which were created when configuring the application link:
-
privatepkcs8-stripped.pem -
bitbucket-consumer-key -
bitbucket-shared-secret
-
-
An active
kubectlsession with administrative permissions to the destination Kubernetes cluster. See Overview of kubectl.
-
Prepare the Secret:
kind: Secret apiVersion: v1 metadata: name: bitbucket-oauth-config namespace: eclipse-che (1) labels: app.kubernetes.io/component: oauth-scm-configuration app.kubernetes.io/part-of: che.eclipse.org annotations: che.eclipse.org/oauth-scm-server: bitbucket che.eclipse.org/scm-server-endpoint: <bitbucket_server_url> (2) type: Opaque stringData: private.key: <Content_of_privatepkcs8-stripped.pem> (3) consumer.key: <Content_of_bitbucket-consumer-key> (4) shared_secret: <Content_of_bitbucket-shared-secret> (5)1 The Che namespace. The default is eclipse-che.2 The URL of the Bitbucket Server. 3 The content of the privatepkcs8-stripped.pemfile.4 The content of the bitbucket-consumer-keyfile.5 The content of the bitbucket-shared-secretfile. -
Apply the Secret:
$ kubectl apply -f - <<EOF <Secret_prepared_in_the_previous_step> EOF
-
Verify that the output displays
secret/bitbucket-oauth-config created.