Skip to content

Commit

Permalink
Merge pull request #288 from umccr/feat/simple-locations
Browse files Browse the repository at this point in the history
feat: path-based locations
  • Loading branch information
mmalenic authored Jan 6, 2025
2 parents 2971867 + 95b3c9b commit 225f6a3
Show file tree
Hide file tree
Showing 12 changed files with 1,020 additions and 534 deletions.
684 changes: 295 additions & 389 deletions htsget-config/README.md

Large diffs are not rendered by default.

16 changes: 3 additions & 13 deletions htsget-config/examples/config-files/basic.toml
Original file line number Diff line number Diff line change
@@ -1,18 +1,8 @@
# An example of running htsget-rs.
# Run with `cargo run --all-features -- --config htsget-config/examples/config-files/basic.toml`
# Run with `cargo run -p htsget-axum --all-features -- --config htsget-config/examples/config-files/basic.toml`

ticket_server_addr = "127.0.0.1:8080"
data_server_addr = "127.0.0.1:8081"

# Serve data locally from the `data` directory.
[[resolvers]]
regex = '.*'
substitution_string = '$0'
storage.backend = 'Local'

# Serve data from S3 if the id is prefixed with `example_bucket`.
[[resolvers]]
regex = '^(example_bucket)/(?P<key>.*)$'
substitution_string = '$key'
storage.backend = 'S3'
# Uses the first capture group in the regex as the bucket.
# Serve data locally from the `data` directory or from an S3 bucket called `bucket` depending on the prefix.
locations = [ "file://data/file_prefix", "s3://bucket/s3_prefix" ]
28 changes: 12 additions & 16 deletions htsget-config/examples/config-files/c4gh.toml
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
# An example of running htsget-rs with Crypt4GH enabled.
# Run with `cargo run -p htsget-axum --features experimental -- --config htsget-config/examples/config-files/c4gh.toml`
# Run with `cargo run -p htsget-axum --features experimental,s3-storage -- --config htsget-config/examples/config-files/c4gh.toml`

ticket_server_addr = "127.0.0.1:8080"
data_server_addr = "127.0.0.1:8081"
ticket_server.addr = "127.0.0.1:8080"
data_server.addr = "127.0.0.1:8081"

[[resolvers]]
[[locations]]
regex = ".*"
substitution_string = "$0"
backend.kind = "File"

[resolvers.storage]
backend = 'Local'
backend.keys.kind = "File"
backend.keys.private = "data/c4gh/keys/bob.sec" # pragma: allowlist secret
backend.keys.public = "data/c4gh/keys/alice.pub"

[resolvers.storage.keys]
location = "Local"
private_key = "data/c4gh/keys/bob.sec" # pragma: allowlist secret
recipient_public_key = "data/c4gh/keys/alice.pub"

# Or, use AWS secrets manager to store keys.
#[resolvers.storage.keys]
#location = "SecretsManager"
#private_key = "htsget/test_c4gh_private_key" # pragma: allowlist secret
#recipient_public_key = "htsget/test_c4gh_public_key"
## Or, use AWS secrets manager to store keys.
#backend.keys.kind = "SecretsManager"
#backend.keys.private = "htsget/test_c4gh_private_key" # pragma: allowlist secret
#backend.keys.public = "htsget/test_c4gh_public_key"
71 changes: 34 additions & 37 deletions htsget-config/examples/config-files/default.toml
Original file line number Diff line number Diff line change
@@ -1,40 +1,37 @@
# Config generated by running `cargo run -p htsget-axum -- -p`

formatting_style = "Full"
ticket_server_addr = "127.0.0.1:8080"
ticket_server_cors_allow_credentials = false
ticket_server_cors_allow_origins = ["http://localhost:8080"]
ticket_server_cors_allow_headers = "All"
ticket_server_cors_allow_methods = "All"
ticket_server_cors_max_age = 86400
ticket_server_cors_expose_headers = []
data_server_enabled = true
data_server_addr = "127.0.0.1:8081"
data_server_local_path = "./"
data_server_serve_at = ""
data_server_cors_allow_credentials = false
data_server_cors_allow_origins = ["http://localhost:8080"]
data_server_cors_allow_headers = "All"
data_server_cors_allow_methods = "All"
data_server_cors_max_age = 86400
data_server_cors_expose_headers = []

[[resolvers]]
regex = ".*"
substitution_string = "$0"
storage = "Local"

[resolvers.allow_guard]
allow_reference_names = "All"
allow_fields = "All"
allow_tags = "All"
allow_formats = [
"BAM",
"CRAM",
"VCF",
"BCF",
]
allow_classes = [
"body",
"header",
]

[ticket_server]
addr = "127.0.0.1:8080"

[ticket_server.cors]
allow_credentials = false
allow_origins = "Mirror"
allow_headers = "Mirror"
allow_methods = "Mirror"
max_age = 2592000
expose_headers = "All"

[data_server]
addr = "127.0.0.1:8081"
local_path = "./"

[data_server.cors]
allow_credentials = false
allow_origins = "Mirror"
allow_headers = "Mirror"
allow_methods = "Mirror"
max_age = 2592000
expose_headers = "All"

[service_info]

[[locations]]
prefix = ""

[locations.backend]
kind = "File"
scheme = "HTTP"
authority = "127.0.0.1:8081"
local_path = "./"
25 changes: 12 additions & 13 deletions htsget-config/examples/config-files/s3_storage.toml
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
# An example for a server which uses s3 storage with data located in "bucket".
# Run with `cargo run -p htsget-axum --features s3-storage -- --config htsget-config/examples/config-files/s3_storage.toml`

ticket_server_cors_allow_headers = "All"
ticket_server_cors_allow_methods = "All"
ticket_server_cors_allow_credentials = true
ticket_server_cors_max_age = 300
ticket_server.cors.allow_headers = "All"
ticket_server.cors.allow_methods = "All"
ticket_server.cors.allow_credentials = false
ticket_server.cors.max_age = 300

data_server_enabled = false
data_server = "None"

[[resolvers]]
regex = '^(bucket)/(?P<key>.*)$'
substitution_string = '$key'
storage.backend = 'S3'
locations = "s3://bucket"

# Or, set the bucket manually
#[resolvers.storage]
#backend = 'S3'
#bucket = 'bucket'
## Or, set using regex locations
#[[locations]]
#regex = "^(bucket)/(?P<key>.*)$"
#substitution_string = "$key"
#backend.kind = "S3"
#backend.bucket = "bucket"
23 changes: 12 additions & 11 deletions htsget-config/examples/config-files/tls_data_server.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
# An example config file for a TLS data server that uses a local storage backend.
# Run with `cargo run -p htsget-axum -- --config htsget-config/examples/config-files/tls_data_server.toml`

ticket_server_addr = "0.0.0.0:8080"
data_server_addr = "0.0.0.0:8081"
data_server_cors_allow_origins = "All"
data_server_tls.cert = "cert.pem"
data_server_tls.key = "key.pem"
ticket_server.addr = "0.0.0.0:8080"
data_server.addr = "0.0.0.0:8081"
data_server.cors.allow_origins = "All"
data_server.tls.cert = "cert.pem"
data_server.tls.key = "key.pem"

[[resolvers]]
regex = ".*"
substitution_string = "$0"
locations = "file://data"

[resolvers.storage]
backend = 'Local'
use_data_server_config = true
## Or, set using regex locations
#[[locations]]
#regex = ".*"
#substitution_string = "$0"
#backend.kind = "File"
#backend.local_path = "data"
23 changes: 12 additions & 11 deletions htsget-config/examples/config-files/tls_ticket_server.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
# An example config file for a TLS ticket server that uses S3 as a storage backend.
# Run with `cargo run -p htsget-axum --features s3-storage -- --config htsget-config/examples/config-files/tls_ticket_server.toml`

ticket_server_addr = "0.0.0.0:8080"
ticket_server_cors_allow_origins = "All"
ticket_server_tls.cert = "cert.pem"
ticket_server_tls.key = "key.pem"
data_server_addr = "0.0.0.0:8081"
ticket_server.addr = "0.0.0.0:8080"
ticket_server.cors_allow_origins = "All"
ticket_server.tls.cert = "cert.pem"
ticket_server.tls.key = "key.pem"
data_server.addr = "0.0.0.0:8081"

[[resolvers]]
regex = ".*"
substitution_string = "$0"
locations = "s3://bucket"

[resolvers.storage]
backend = 'S3'
bucket = "bucket"
## Or, set using regex locations
#[[locations]]
#regex = ".*"
#substitution_string = "$0"
#backend.kind = "S3"
#backend.bucket = "bucket"
42 changes: 22 additions & 20 deletions htsget-config/examples/config-files/url_storage.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,29 @@
# `cargo run -p htsget-axum --features url-storage -- --config htsget-config/examples/config-files/url_storage.toml`
# in the project directory.

ticket_server_addr = "127.0.0.1:8082"
ticket_server_cors_allow_origins = "All"
ticket_server.addr = "127.0.0.1:8082"
ticket_server.cors.allow_origins = "All"

ticket_server_cert = "cert.pem"
ticket_server_key = "key.pem"
ticket_server.tls.cert = "cert.pem"
ticket_server.tls.key = "key.pem"

data_server_enabled = false
data_server = "None"

[[resolvers]]
regex = ".*"
substitution_string = "$0"
locations = "https://127.0.0.1:8081"

[resolvers.storage]
backend = 'Url'
url = "http://127.0.0.1:8081"
response_url = "https://127.0.0.1:8081"
forward_headers = true

# Set client authentication
#tls.key = "key.pem"
#tls.cert = "cert.pem"

# Set root certificates
#tls.root_store = "cert.pem"
## Or, set using regex locations
#[[locations]]
#regex = ".*"
#substitution_string = "$0"
#
#backend.kind = "Url"
#backend.url = "http://127.0.0.1:8081"
#backend.response_url = "https://127.0.0.1:8081"
#backend.forward_headers = true
#
## Set client authentication
#backend.tls.key = "key.pem"
#backend.tls.cert = "cert.pem"
#
## Set root certificates
#backend.tls.root_store = "root.crt"
Loading

0 comments on commit 225f6a3

Please sign in to comment.