コード例

KeeperPAMでのポストスクリプトローテーションスクリプト例

エコー入力

以下のポストローテーション後スクリプトの例では、入力パラメータを様々な言語とプラットフォームでエコーしています。print文の出力はKeeperゲートウェイのログファイルで確認できます。

Bash

注: この例では、 JSONを解析するためにjqがインストールされている必要があります。このコードをPAMスクリプトとして添付してローテーションを実行します。出力はゲートウェイのログファイルに含まれます。

decode-and-echo.sh
#!/bin/bash

# Read the Base64 encoded JSON input and decode it
decoded_json=$(cat | base64 --decode)

# Extract the "records" field, which is Base64 encoded, and decode it separately
records_base64=$(echo "$decoded_json" | jq -r '.records')

# Decode the Base64 "records" field and pretty-print the JSON
decoded_records=$(echo "$records_base64" | base64 --decode | jq '.')

# Print the entire decoded JSON, replacing "records" with the decoded version
echo "$decoded_json" | jq --argjson records "$decoded_records" '.records = $records'

PowerShell

以下のコードをPAMスクリプトとして添付し、ローテーションを実行します。Keeperゲートウェイのログファイルに出力が含まれます。このスクリプトは入力をそのままエコーします。

以下は、Webhookをサードパーティのウェブサイトに送信するPowerShellスクリプトとなります。

KeeperシークレットマネージャーSDKの使用

ポストローテーションスクリプトはシェルスクリプトに限定されません。PythonやC#などの言語でアプリケーションを作成し、パイプされたパラメータを取得することもできます。ローテーションに関係するレコードUIDがパラメータとして渡されるため、ポストローテーションスクリプトでKeeperシークレットマネージャーSDKを使用して追加情報を取得できます。

最終更新