9.3.5.2. Bitbucket Server OAuth 1 の設定

この手順では、Bitbucket Server の OAuth 1 をアクティベートして以下を実行する方法を説明します。

これは CodeReady Workspaces が Bitbucket Server Personal アクセストークンを取得し、更新できるようにします。

前提条件

  • oc ツールが利用できる。
  • Bitbucket サーバーは、CodeReady Workspaces サーバーから利用できます。

手順

  1. RSA キーペアと公開鍵の省略バージョンを生成します。

    openssl genrsa -out <private.pem> 2048
    openssl rsa -in <private.pem> -pubout > <public.pub>
    openssl pkcs8 -topk8 -inform pem -outform pem -nocrypt -in <private.pem> -out <privatepkcs8.pem>
    cat <public.pub> | sed 's/-----BEGIN PUBLIC KEY-----//g' | sed 's/-----END PUBLIC KEY-----//g' | tr -d '\n' > <public-stripped.pub>
  2. コンシューマーキーと共有シークレットを生成します。

    openssl rand -base64 24 > <bitbucket_server_consumer_key>
    openssl rand -base64 24 > <bitbucket_shared_secret>
  3. コンシューマーおよびプライベートキーを含む Kubernetes シークレットを CodeReady Workspaces namespace に作成します。

    $ oc apply -f - <<EOF
    kind: Secret
    apiVersion: v1
    metadata:
      name: bitbucket-oauth-config
      namespace: <...> 1
      labels:
        app.kubernetes.io/part-of: che.eclipse.org
        app.kubernetes.io/component: oauth-scm-configuration
      annotations:
        che.eclipse.org/oauth-scm-server: bitbucket
        che.eclipse.org/scm-server-endpoint: <...> 2
    type: Opaque
    data:
      private.key: <...> 3
      consumer.key: <...> 4
    EOF
    1
    CodeReady Workspaces namespace。デフォルトは openshift-workspaces です。
    2
    Bitbucket サーバー URL
    3
    最初の行と最後の行のない <privatepkcs8.pem> ファイルの base64 でエンコードされたコンテンツ。
    4
    <bitbucket_server_consumer_key> ファイルの base64 でエンコードされたコンテンツ。
  4. Bitbucket でアプリケーションリンクを設定し、CodeReady Workspaces から Bitbucket サーバーへの通信を有効にします。

    1. Bitbucket Server で上部のナビゲーションバーをクリックし、Administration > Application Links に移動します。

  1. アプリケーション URL: \https://codeready-<openshift_deployment_name>.<domain_name> を入力し、Create new link ボタンをクリックします。

  1. 「No response was received from the URL」という警告メッセージが表示されたら Continue ボタンをクリックします。

  1. Link Applications フォームを入力し、Continue ボタンをクリックします。

    Application Name
    <CodeReady Workspaces>
    Application Type
    Generic Application
    Service Provider Name
    <CodeReady Workspaces>
    Consumer Key
    <bitbucket_server_consumer_key> ファイルの内容を貼り付けます。
    Shared secret
    <bitbucket_shared_secret> ファイルの内容を貼り付けます。
    Request Token URL
    <Bitbucket Server URL>/plugins/servlet/oauth/request-token
    アクセストークン URL
    <Bitbucket Server URL>/plugins/servlet/oauth/access-token
    Authorize URL
    <Bitbucket Server URL>/plugins/servlet/oauth/access-token
    Create incoming link
    Enabled
  2. Link Applications フォームを入力し、Continue ボタンをクリックします。

    Consumer Key
    <bitbucket_server_consumer_key> ファイルの内容を貼り付けます。
    Consumer name
    <CodeReady Workspaces>
    Public Key
    <public-stripped.pub> ファイルの内容を貼り付けます。