Data Hub File Service - a service enabling file inspection and re-encryption at Data Hubs
3.2K
Data Hub File Service - a service enabling file inspection and re-encryption at Data Hubs
The service ships as the container image ghga/dhfs and the Helm chart dhfs.
The DHFS communicates with the GHGA Central API and with the Data Hub's own S3 instance in order to perform re-encryption of files initially encrypted and uploaded by submitters.
Within GHGA Central services, file upload activity is tracked and broadcasted through Kafka events.
However, DHFS is not connected to GHGA Central's Kafka network.
Instead, a dedicated service at GHGA Central liaises between DHFS instances and the rest of GHGA Central, ensuring that DHFS instances only receive information about files uploaded to their S3 instance.
Because this communication occurs through a public-facing HTTP API, DHFS requests are authenticated by DHFS-signed JSON Web Tokens.
Each Data Hub must therefore generate a key pair in JWK format and share the public key with GHGA Central.
The key pair must be of type EC P-256, which provides strong security at compact key sizes.
The created private key must be set as the data_hub_signing_key configuration value.
Example for JWK generation with Python and the jwcrypto library:
from jwcrypto.jwk import JWK
jwk = JWK.generate(kid="HD01-DHFS-2026-04", kty="EC", crv="P-256")
with open("jwk.pub", "w") as pk, open("jwk.sec", "w") as sk:
pk.write(jwk.export_public())
sk.write(jwk.export_private())
Crypt4GH keys are used in two different capacities.
The first is for decrypting symmetric file encryption secrets generated by file submitters.
During the upload process, the GHGA Connector will encrypt the file content with a key randomly generated according to the Crypt4GH standard (32-bytes).
The GHGA Connector encrypts this key using the recipient Data Hub's Crypt4GH public key and includes it at the beginning of the uploaded file, before any of the actual file content.
When DHFS starts the re-encryption process for the file, it first fetches the encrypted file secret and decrypts it using the Data Hub's matching Crypt4GH private key.
Since Crypt4GH supports passphrase protection for private keys, DHFS configuration requires the key's path instead of the key itself.
The key path is set as data_hub_crypt4gh_private_key_path, and the passphrase, if applicable, is set as data_hub_crypt4gh_private_key_passphrase.
The second use for Crypt4GH is to securely transfer the new file encryption secret to GHGA Central after file re-encryption.
This key that the data hub should use for this purpose must be passed in the configuration setting central_api_crypt4gh_public_key.
The executable dhfs takes one of these commands:
interrogate runs the file interrogation and re-encryption processcleanup cleans up the S3 interrogation bucketverify re-encrypts a dummy file to verify that the service works with the current S3 backendRunning a service shows how to start, build and deploy it.
The settings take the prefix dhfs: the environment variable DHFS_HOST sets host, and the YAML file is .dhfs.yaml.
example_config.yaml holds a complete set to adapt, and Configuration says where the service looks for them.
The service requires the following configuration parameters:
client_exponential_backoff_max (integer): Maximum number of seconds to wait between retries when using exponential backoff retry strategies.
The client timeout might need to be adjusted accordingly.
Minimum: 0.
Default: 60.
client_num_retries (integer): Number of times to retry failed API calls.
Minimum: 0.
Default: 3.
client_retry_status_codes (array): List of status codes that should trigger retrying a request.
Default: [408, 429, 500, 502, 503, 504].
client_reraise_from_retry_error (boolean): Specifies if the exception wrapped in the final RetryError is reraised or the RetryError is returned as is.
Default: true.
min_request_interval (number): Minimum number of seconds between requests to one host and first path segment.
If left at 0 some jitter is still added to pace concurrent requests.
Minimum: 0.
Default: 0.0.
per_request_jitter (number): Max amount of jitter (in seconds) to add to each request.
Minimum: 0.
Default: 0.05.
http_request_timeout_seconds (number): Request timeout setting in seconds.
Default: 60.0.
data_hub_crypt4gh_public_key_path: Path to the Data Hub's Crypt4GH public key file.
Only needed for running dhfs verify.
Default: null.
Examples:
"./key.pub"
inbox_bucket_id: The inbox bucket ID - only needed for running dhfs verify.
Default: null.
Examples:
"inbox"
"hub-inbox"
inbox_write_s3_access_key_id: S3 access key ID with write access to the inbox bucket.
Only needed for running dhfs verify.
Default: null.
Examples:
"my-write-access-key-id"
inbox_write_s3_secret_access_key: S3 secret access key with write access to the inbox bucket.
Only needed for running dhfs verify.
Default: null.
inbox_write_s3_session_token: Optional S3 session token for the write-capable inbox credentials.
Only needed for running dhfs verify.
Default: null.
data_hub_crypt4gh_private_key_path (string, format: path, required): Path to the Data Hub's Crypt4GH private key file.
Examples:
"./key.sec"
data_hub_crypt4gh_private_key_passphrase: Passphrase needed to read the content of the private key file.
Only needed if the private key is encrypted.
Default: null.
central_api_crypt4gh_public_key (string, required): The Crypt4GH public key used by the Central API.
This is used to encrypt new file encryption secrets.
central_api_url (string, format: uri, required): The base URL used to connect to to the GHGA Central API.
Length must be between 1 and 2083 (inclusive).
data_hub_signing_key (string, format: password, required and write-only): The Data Hub's private JWK for signing JWT auth tokens.
Examples:
"{\"crv\": \"P-256\", \"kty\": \"EC\", \"x\": \"...\", \"y\": \"...\", \"d\": \"...\"}"
storage_alias (string, required): An alias identifying the Data Hub at which this instance of DHFS is running.
This value should be set in coordination with GHGA Central.
Examples:
"HD01"
"TUE01"
"B01"
s3_endpoint_url (string, required): URL to the S3 API.
Examples:
"http://localhost:4566"
s3_access_key_id (string, required): Part of credentials for login into the S3 service.
See: https://boto3.amazonaws.com/v1/documentation/api/latest/guide/credentials.html.
Examples:
"my-access-key-id"
s3_secret_access_key (string, format: password, required and write-only): Part of credentials for login into the S3 service.
See: https://boto3.amazonaws.com/v1/documentation/api/latest/guide/credentials.html.
Examples:
"my-secret-access-key"
s3_session_token: Part of credentials for login into the S3 service.
See: https://boto3.amazonaws.com/v1/documentation/api/latest/guide/credentials.html.
Default: null.
Examples:
"my-session-token"
aws_config_ini: Path to a config file for specifying more advanced S3 parameters.
This should follow the format described here: https://boto3.amazonaws.com/v1/documentation/api/latest/guide/configuration.html#using-a-configuration-file.
Default: null.
Examples:
"~/.aws/config"
log_level (string): The minimum log level to capture.
Must be one of: "CRITICAL", "ERROR", "WARNING", "INFO", "DEBUG", or "TRACE".
Default: "INFO".
service_name (string): Short name of this service.
Default: "dhfs".
service_instance_id (string, required): A string that uniquely identifies this instance across all instances of this service.
This is included in log messages.
Examples:
"germany-bw-instance-001"
log_format: If set, will replace JSON formatting with the specified string format.
If not set, has no effect.
In addition to the standard attributes, the following can also be specified: timestamp, service, instance, level, correlation_id, and details.
Default: null.
Examples:
"%(timestamp)s - %(service)s - %(level)s - %(message)s"
"%(asctime)s - Severity: %(levelno)s - %(msg)s"
log_traceback (boolean): Whether to include exception tracebacks in log messages.
Default: true.
min_run_interval_seconds (integer): The minimum number of seconds to wait before asking the CentralAPI about new files for interrogation.
DHFS asks again immediately after a round that concluded at least one file, though.
Default: 60.
interrogation_bucket_id (string, required): The name for the S3 'interrogation' bucket, which houses re-encrypted files until they are copied to permanent storage by IFRS.
max_concurrent_parts (integer): How many file parts to process at the same time.
Files are processed one at a time, so this is the whole budget for the file in flight.
It lets the download of one part overlap the re-encryption of another and the upload of a third, and it is the service's memory budget: peak use is roughly max_concurrent_parts * 3 * part size.
Minimum: 1.
Default: 8.
library_log_level (string): The log level to use for libraries.
This option can be used in tandem with log_level to view DEBUG logs from DHFS without the noise of third-party libraries.
Will be overridden by log_level if log_level is higher.
By default, this is set to CRITICAL, which will suppress all logs with a log level lower than CRITICAL.
Must be one of: "CRITICAL", "ERROR", "WARNING", "INFO", "DEBUG", or "TRACE".
Default: "CRITICAL".
library_logger_names (array): The list of logger names to target with library_log_level.
Default: ["httpx2", "crypt4gh", "hexkit", "ghga_service_commons", "boto3", "botocore", "httpcore2", "urllib3"].
This is a Python-based service following the Triple Hexagonal Architecture pattern. It uses protocol/provider pairs and dependency injection mechanisms provided by the hexkit library.
This repository is free to use and modify according to the Apache 2.0 License.
docker pull ghga/dhfs:16.1.0Last week