シークレットマネージャークライアントコマンド
アプリごとに作成されるクライアントに関するKeeperシークレットマネージャーコマンドの利用
最終更新
My Vault> secrets-manager-client --command add --app="ksm_app_uid" --name "test client"
Successfully generated Client Device
====================================
One-Time Access Token: US:access_token
Name: test client
IP Lock: Enabled
Token Expires On: 2025-11-05 16:20:14
App Access Expires on: Never
Warning: Configuration is now locked to your current IP. To keep in unlock you can add flag `--unlock-ip` or use the One-time token to generate configuration on the host that has the IP that needs to be locked.
master_key = vault.vault_data.get_record_key(record_uid=app_uid)
if not master_key:
raise ValueError(f"Could not retrieve app key for application {app_uid}")
server = keeper_auth_context.keeper_endpoint.server
current_time_ms = int(time.time() * MILLISECONDS_PER_SECOND)
first_access_expire_duration_ms = (
current_time_ms + first_access_expires_in_minutes * MILLISECONDS_PER_MINUTE
)
access_expire_in_ms = (
access_expire_in_minutes * MILLISECONDS_PER_MINUTE
if access_expire_in_minutes else None
)
for i in range(count):
result = ksm_management.KSMClientManagement.add_client_to_ksm_app(
vault=vault,
uid=app_uid,
client_name=client_name or "",
count=count,
index=i,
unlock_ip=unlock_ip,
first_access_expire_duration_ms=first_access_expire_duration_ms,
access_expire_in_ms=access_expire_in_ms,
master_key=master_key,
server=server,
)
print(result["output_string"])
if result.get("token_info"):
print(f" One-Time Token: {result['token_info'].get('oneTimeToken', '')}")My Vault> ksm delete-client ksm_app_uid --client-name "Example Client"
Client "Example Client" has been deleted from application Test_Gateway Applicationpublic async Task DeleteSecretManagerClient(string applicationId, string deviceId)var applicationId = "<AppId>";
var deviceId = "<deviceId>";
await vault.DeleteSecretManagerClient(applicationId, deviceId);PS > Remove-KeeperSecretManagerClient -App ksm_app_uid -Name "Example Device" -Confirm
Confirm
Are you sure you want to perform this action?
Performing the operation "Removing KSM Device 'Example Device'" on target "Test_Gateway Application".
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"): YMy Vault> secrets-manager-client --command remove --app="ksm-app-uid" -i "client-uid"
Are you sure you want to delete 1 matching client(s) from this application? [y/n]: y
Client removal was successful
My Vault>ksm_management.KSMClientManagement.remove_clients_from_ksm_app(
vault=vault,
uid=app_uid,
client_names_and_ids=client_ids, ##only client ids are supported
callable=confirm_remove,
)