カスタム暗号化

このページの内容

お困りですか?

アトラシアン コミュニティをご利用ください。

コミュニティに質問

Confluence サイトのセキュリティを強化するために、confluence.cfg.xml ファイルに保存されているデータベース パスワードを暗号化できます。

Confluence に用意されている基本的な暗号化方法、高度な暗号化方法、または AWS Secrets Manager の暗号化方法を使用しない場合は、独自の SecretStore 実装を作成できます。これは、特に次のような場合に役立ちます。

  • パスワードを保存するのに特定のボールトを使用する必要がある。
  • 別の暗号化アルゴリズムを使用したい。

この手順では、Java と Maven に精通していることを前提としています。 

On this page:

ステップ 1. Maven プロジェクトを作成して API 依存関係を取得する

Maven プロジェクトを作成して API 依存関係を取得するには、次の手順に従います。

  1. <install-directory>/confluence/WEB-INF/lib ディレクトリに移動します。

  2. 次のコマンドを使用して、atlassian-secrets-api.jar ファイルをローカルの Maven リポジトリにインストールします。

    mvn install:install-file \
       -Dfile=./atlassian-secrets-api-<version>.jar \
       -DgroupId=com.atlassian.secrets \
       -DartifactId=atlassian-secrets-api \
       -Dversion=<version> \
       -Dpackaging=jar \
       -DgeneratePom=true
  3. 次のコマンドを使用して、atlassian-secrets-store.jar ファイルをローカルの Maven リポジトリにインストールします。

    mvn install:install-file \
       -Dfile=./atlassian-secrets-store-<version>.jar \
       -DgroupId=com.atlassian.secrets \
       -DartifactId=atlassian-secrets-store \
       -Dversion=<version> \
       -Dpackaging=jar \
       -DgeneratePom=true
  4. 次の pom を使用して Maven プロジェクトを作成します。

    <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
     
      <groupId><your_group_ID></groupId>
      <artifactId><your_artifact_ID></artifactId>
      <version><your_version></version>
     
      <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
      </properties>
    
      <build>
        <resources>
          <resource>
            <directory>src/main/resources/libs</directory>
            <excludes>
              <exclude>*</exclude>
            </excludes>
            <filtering>false</filtering>
          </resource>
        </resources>
      </build>
     
      <dependencies>
        <dependency>
          <groupId>com.atlassian.secrets</groupId>
          <artifactId>atlassian-secrets-api</artifactId>
          <version><api_version></version>
          <scope>provided</scope>
        </dependency>
        <dependency>
          <groupId>com.atlassian.secrets</groupId>
          <artifactId>atlassian-secrets-store</artifactId>
          <version><api_version></version>
          <scope>provided</scope>
        </dependency>
      </dependencies>
    </project>

ステップ 2. SecretStore インターフェイスを実装する

SecretStore インターフェイスには、要件に応じて実装する必要がある 2 つのメソッド storeget が含まれています。get メソッドは Confluence の起動中に呼び出されるため、長期実行タスクが起動時間に影響を与える可能性があります。暗号化ツールでのみ使用されるため、store メソッドが Confluence から呼び出されることはありません。

Confluence 8.6 以降では、Cipher インターフェイスは廃止されたものと見なしてください。代わりに、新しいインターフェイスの SecretStore とそのメソッド store および get を使用してください。これらのメソッドは、対応する Cipher インターフェイスのメソッド encrypt および decrypt に優先します。

Cipher インターフェイスとそのメソッドは引き続き使用できますが、将来的には廃止されるため、新しい暗号化機能を設定するときには使用しないでください。

例として Base64SecretStoreAlgorithmSecretStore を使用できます。

ステップ 3. 実装をテストする

The encryption tool described in Base64 encoding and AES encryption uses the same code as Confluence to decrypt the password. You can use it to test your implementation.

CLI と jar が同じフォルダーにあるとします。

java -cp "./*" com.atlassian.secrets.cli.db.DbCipherTool -c your.package.here.ClassName

ステップ 4. ライブラリを利用可能にする

Confluence がライブラリにアクセスできる必要があります。リフレクションによってクラスはインスタンス化されます。

ライブラリを <install-directory>/confluence/WEB-INF/lib ディレクトリに置きます。


最終更新日: 2023 年 10 月 13 日

この内容はお役に立ちましたか?

はい
いいえ
この記事についてのフィードバックを送信する
Powered by Confluence and Scroll Viewport.