2020-03-04 22:10:58 +00:00
# Custom Actions
The `actions` struct inside the "sftpd" configuration section allows to configure the actions for file operations and SSH commands.
2020-04-03 17:25:38 +00:00
The `upload` condition includes both uploads to new files and overwrite of existing files. The `ssh_cmd` condition will be triggered after a command is successfully executed via SSH. `scp` will trigger the `download` and `upload` conditions and not `ssh_cmd` .
The notification will indicate if an error is detected and so, for example, a partial file is uploaded.
2020-03-04 22:10:58 +00:00
The `command` , if defined, is invoked with the following arguments:
- `action` , string, possible values are: `download` , `upload` , `delete` , `rename` , `ssh_cmd`
- `username`
- `path` is the full filesystem path, can be empty for some ssh commands
2020-03-25 17:36:33 +00:00
- `target_path` , non-empty for `rename` action
- `ssh_cmd` , non-empty for `ssh_cmd` action
2020-03-04 22:10:58 +00:00
The `command` can also read the following environment variables:
- `SFTPGO_ACTION`
- `SFTPGO_ACTION_USERNAME`
- `SFTPGO_ACTION_PATH`
2020-03-25 17:36:33 +00:00
- `SFTPGO_ACTION_TARGET` , non-empty for `rename` `SFTPGO_ACTION`
- `SFTPGO_ACTION_SSH_CMD` , non-empty for `ssh_cmd` `SFTPGO_ACTION`
- `SFTPGO_ACTION_FILE_SIZE` , non-empty for `upload` , `download` and `delete` `SFTPGO_ACTION`
- `SFTPGO_ACTION_FS_PROVIDER` , `0` for local filesystem, `1` for S3 backend, `2` for Google Cloud Storage (GCS) backend
- `SFTPGO_ACTION_BUCKET` , non-empty for S3 and GCS backends
- `SFTPGO_ACTION_ENDPOINT` , non-empty for S3 backend if configured
2020-04-03 17:25:38 +00:00
- `SFTPGO_ACTION_STATUS` , integer. 0 means an error occurred. 1 means no error
2020-03-04 22:10:58 +00:00
Previous global environment variables aren't cleared when the script is called.
The `command` must finish within 30 seconds.
2020-03-25 17:36:33 +00:00
The `http_notification_url` , if defined, will be invoked as HTTP POST. The request body will contain a JSON serialized struct with the following fields:
2020-03-04 22:10:58 +00:00
- `action`
- `username`
- `path`
2020-03-25 17:36:33 +00:00
- `target_path` , not null for `rename` action
- `ssh_cmd` , not null for `ssh_cmd` action
- `file_size` , not null for `upload` , `download` , `delete` actions
- `fs_provider` , `0` for local filesystem, `1` for S3 backend, `2` for Google Cloud Storage (GCS) backend
- `bucket` , not null for S3 and GCS backends
- `endpoint` , not null for S3 backend if configured
2020-04-03 17:25:38 +00:00
- `status` , integer. 0 means an error occurred. 1 means no error
2020-03-25 17:36:33 +00:00
2020-03-04 22:10:58 +00:00
2020-04-26 21:29:09 +00:00
The HTTP request will use the global configuration for HTTP clients.
2020-03-04 22:10:58 +00:00
The `actions` struct inside the "data_provider" configuration section allows you to configure actions on user add, update, delete.
Actions will not be fired for internal updates, such as the last login or the user quota fields, or after external authentication.
The `command` , if defined, is invoked with the following arguments:
- `action` , string, possible values are: `add` , `update` , `delete`
- `username`
- `ID`
- `status`
- `expiration_date`
- `home_dir`
- `uid`
- `gid`
The `command` can also read the following environment variables:
- `SFTPGO_USER_ACTION`
- `SFTPGO_USER_USERNAME`
- `SFTPGO_USER_PASSWORD` , hashed password as stored inside the data provider, can be empty if the user does not login using a password
- `SFTPGO_USER_ID`
- `SFTPGO_USER_STATUS`
- `SFTPGO_USER_EXPIRATION_DATE`
- `SFTPGO_USER_HOME_DIR`
- `SFTPGO_USER_UID`
- `SFTPGO_USER_GID`
- `SFTPGO_USER_QUOTA_FILES`
- `SFTPGO_USER_QUOTA_SIZE`
- `SFTPGO_USER_UPLOAD_BANDWIDTH`
- `SFTPGO_USER_DOWNLOAD_BANDWIDTH`
- `SFTPGO_USER_MAX_SESSIONS`
- `SFTPGO_USER_FS_PROVIDER`
Previous global environment variables aren't cleared when the script is called.
The `command` must finish within 15 seconds.
2020-03-25 17:36:33 +00:00
The `http_notification_url` , if defined, will be invoked as HTTP POST. The action is added to the query string, for example `<http_notification_url>?action=update` , and the user is sent serialized as JSON inside the POST body with sensitive fields removed.
2020-03-04 22:10:58 +00:00
2020-04-26 21:29:09 +00:00
The HTTP request will use the global configuration for HTTP clients.