Skip to content
Merged

Release #1863

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions docker_ksm_utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,10 @@ def _get_secret_by_uid_or_title(secrets_manager, record_identifier):
def download_config(ksm_config_path, ksm_token, record_identifier, output_path):
"""
Download config.json from KSM record.

Tries file attachments first. If no config.json attachment exists
(e.g. the account has no file storage plan), falls back to the
``config_json`` custom field written by the setup commands.

Args:
ksm_config_path (str): Path to KSM config file (optional)
Expand Down Expand Up @@ -344,15 +348,24 @@ def download_config(ksm_config_path, ksm_token, record_identifier, output_path):
if not secret:
return False

# Find config.json attachment
# Try file attachment first
for file in secret.files:
if file.name.lower() == 'config.json':
# Ensure output directory exists
os.makedirs(os.path.dirname(output_path), exist_ok=True)
file.save_file(output_path, True)
return True

print("ERROR: config.json attachment not found in record")
# Fallback: check for config_json custom field
config_value = secret.custom_field('config_json', single=True)
if config_value:
os.makedirs(os.path.dirname(output_path), exist_ok=True)
with open(output_path, 'w', encoding='utf-8') as f:
f.write(config_value)
os.chmod(output_path, 0o600)
print("config.json restored from custom field")
return True

print("ERROR: config.json not found as attachment or custom field in record")
return False

except Exception as e:
Expand Down
158 changes: 158 additions & 0 deletions examples/pam-kcm-import/KCM_mappings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
{
"users":{
"username":"login",
"password":"password",
"private-key": "private_pem_key",
"public-key": "log",
"passphrase": "log",
"totp-algorithm": "totp-algorithm",
"totp-digits": "totp-digits",
"totp-period": "totp-period",
"totp-secret": "totp-secret"
},
"resources":{
"domain": "domain_name",
"create-recording-path": "pam_settings.options.graphical_session_recording=on",
"create-typescript-path": "pam_settings.options.text_session_recording=on",
"recording-include-keys": "pam_settings.connection.recording_include_keys",
"security": "pam_settings.connection.security",
"color-depth": null,
"enable-audio": null,
"disable-copy": "pam_settings.connection.disable_copy",
"disable-paste": "pam_settings.connection.disable_paste",
"force-lossless": null,
"read-only": null,
"backspace": null,
"url": "url",
"allow-url-manipulation": "pam_settings.connection.allow_url_manipulation",
"ignore-initial-ssl-cert": null,
"allowed-resource-url-patterns": "pam_settings.connection.allowed_resource_url_patterns",
"allowed-url-patterns": "pam_settings.connection.allowed_url_patterns",
"autofill-configuration": "pam_settings.connection.autofill_targets",
"disable-audio": "pam_settings.connection.disable_audio",
"audio-bps": null,
"audio-channels": null,
"audio-sample-rate": null,
"ca-cert": "pam_settings.connection.ca_certificate",
"client-cert": "pam_settings.connection.client_certificate",
"client-key": "pam_settings.connection.client_key",
"color-scheme": "pam_settings.connection.color_scheme",
"font-name": null,
"font-size": "pam_settings.connection.font_size",
"scrollback": null,
"ignore-cert": "pam_settings.connection.ignore_server_cert",
"namespace": "pam_settings.connection.namespace",
"pod": "pam_settings.connection.pod_name",
"container": "pam_settings.connection.container",
"use-ssl": "use_ssl",
"database": "pam_settings.connection.default_database",
"disable-csv-export": "pam_settings.connection.disable_csv_export",
"disable-csv-import": "pam_settings.connection.disable_csv_import",
"client-name": null,
"console": null,
"console-audio": null,
"disable-auth": "pam_settings.connection.disable_authentication",
"disable-bitmap-caching": null,
"disable-glyph-caching": null,
"disable-offscreen-caching": null,
"dpi": null,
"enable-audio-input": null,
"disable-display-resize": "pam_settings.connection.disable_dynamic_resizing",
"enable-desktop-composition": "pam_settings.connection.enableDesktopComposition",
"enable-font-smoothing": "pam_settings.connection.enableFontSmooting",
"enable-full-window-drag": "pam_settings.connection.enable_full_window_drag",
"enable-menu-animations": null,
"enable-printing": null,
"enable-theming": null,
"enable-touch": null,
"enable-wallpaper": "pam_settings.connection.enable_wallpaper",
"initial-program": null,
"load-balance-info": "pam_settings.connection.load_balance_info",
"normalize-clipboard": null,
"preconnection-blob": "pam_settings.connection.preconnection_blob",
"preconnection-id": "pam_settings.connection.preconnection_id",
"printer-name": null,
"remote-app": null,
"remote-app-args": null,
"remote-app-dir": null,
"resize-method": null,
"timezone": null,
"width": null,
"height": null,
"locale": null,
"host-key": "pam_settings.connection.public_host_key",
"command": "pam_settings.connection.command",
"server-alive-interval": null,
"terminal-type": null,
"login-failure-regex": "pam_settings.connection.login_failure_regex",
"login-success-regex": "pam_settings.connection.login_success_regex",
"password-regex": "pam_settings.connection.password_regex",
"username-regex": "pam_settings.connection.username_regex",
"audio-servername": null,
"clipboard-buffer-size": null,
"clipboard-encoding": null,
"compress-level": null,
"cursor": null,
"dest-host": null,
"dest-port": null,
"disable-server-input": null,
"encodings": null,
"quality-level": null,
"swap-red-blue": null,
"wol-broadcast-addr": null,
"wol-mac-addr": null,
"wol-send-packet": null,
"wol-udp-port": null,
"wol-wait-time": null,
"create-profile-directory": null,
"profile-storage-directory": null,
"exec-command": null,
"unix-socket": null,
"cert-fingerprints": null,
"cert-tofu": null,
"disable-download": null,
"disable-gfx": null,
"disable-upload": null,
"drive-name": null,
"drive-path": null,
"enable-drive": null,
"create-drive-path": null,
"gateway-domain": null,
"gateway-hostname": null,
"gateway-password": null,
"gateway-port": null,
"gateway-username": null,
"server-layout": null,
"static-channels": null,
"timeout": null,
"ca-certificate": null,
"disable-cert-hostname-verification": null,
"force-encryption": null,
"protocol-version": null,
"ksm-user-config-enabled": "ignore",
"recording-name": "ignore",
"recording-path": "ignore",
"recording-write-existing": "ignore",
"typescript-name": "ignore",
"typescript-path": "ignore",
"typescript-write-existing": "ignore",
"recording-exclude-mouse": null,
"recording-exclude-output": null,
"recording-exclude-touch": null,
"enable-sftp": "pam_settings.connection.sftp.enable_sftp",
"sftp-directory": "pam_settings.connection.sftp.sftp_upload_directory",
"sftp-disable-download": null,
"sftp-disable-upload": null,
"sftp-host-key": null,
"sftp-hostname": "pam_settings.connection.sftp.host",
"sftp-passphrase": null,
"sftp-password": "pam_settings.connection.sftp.password",
"sftp-port": "pam_settings.connection.sftp.port",
"sftp-private-key": "pam_settings.connection.sftp.private_key",
"sftp-public-key": null,
"sftp-root-directory": "pam_settings.connection.sftp.sftp_root_directory",
"sftp-server-alive-interval": "pam_settings.connection.sftp.sftp_keepalive_interval",
"sftp-timeout":null,
"sftp-username": "pam_settings.connection.sftp.login"
}
}
Loading
Loading