Skip to content

Commit

Permalink
separated exporter API key CLA from auth header (#191)
Browse files Browse the repository at this point in the history
  • Loading branch information
enola-dkfz authored Dec 6, 2024
1 parent 69e342e commit 97cb1d6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ PROJECTS_NO_OBFUSCATION = "exliquid;dktk_supervisors;exporter;ehds2" # Projects
QUERIES_TO_CACHE = "queries_to_cache.conf" # The path to a file containing base64 encoded queries whose results are to be cached. If not set, no results are cached
PROVIDER = "name" #EUCAIM provider name
PROVIDER_ICON = "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEUAAACnej3aAAAAAXRSTlMAQObYZgAAAApJREFUCNdjYAAAAAIAAeIhvDMAAAAASUVORK5CYII=" # Base64 encoded EUCAIM provider icon
AUTH_HEADER = "ApiKey XXXX" #Authorization header; if the endpoint type is Blaze or BlazeAndSql, this header is used for the Exporter target application, and the syntax is AUTH_HEADER = "XXXX" where "XXXX" is the API key
AUTH_HEADER = "[Auth Type] XXXX" #Authorization header for accessing the store; Auth Type e.g. ApiKey, Basic, ...
EXPORTER_API_KEY = "XXXX" # Value of header x-api-key for accessing the Exporter application
```

In order to use Postgres querying, a Docker image built with the feature "dktk" needs to be used and this optional variable set:
Expand Down
7 changes: 7 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,15 @@ struct CliArgs {
#[clap(long, env, value_parser)]
provider_icon: Option<String>,

// TODO - refactor to include multiple authorization headers for multiple stores / applications at the same time
/// Authorization header
#[clap(long, env, value_parser)]
auth_header: Option<String>,

/// Exporter API key
#[clap(long, env, value_parser)]
exporter_api_key: Option<String>,

/// Postgres connection string
#[cfg(feature = "query-sql")]
#[clap(long, env, value_parser)]
Expand Down Expand Up @@ -198,6 +203,7 @@ pub(crate) struct Config {
pub provider: Option<String>,
pub provider_icon: Option<String>,
pub auth_header: Option<String>,
pub exporter_api_key: Option<String>,
#[cfg(feature = "query-sql")]
pub postgres_connection_string: Option<String>,
#[cfg(feature = "query-sql")]
Expand Down Expand Up @@ -243,6 +249,7 @@ impl Config {
provider: cli_args.provider,
provider_icon: cli_args.provider_icon,
auth_header: cli_args.auth_header,
exporter_api_key: cli_args.exporter_api_key,
#[cfg(feature = "query-sql")]
postgres_connection_string: cli_args.postgres_connection_string,
#[cfg(feature = "query-sql")]
Expand Down
4 changes: 2 additions & 2 deletions src/exporter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ pub async fn post_exporter_query(body: &String, task_type: TaskType) -> Result<S

let mut headers = HeaderMap::new();

if let Some(auth_header_value) = CONFIG.auth_header.clone() {
if let Some(api_key) = CONFIG.exporter_api_key.clone() {
headers.insert(
"x-api-key",
HeaderValue::from_str(auth_header_value.as_str())
HeaderValue::from_str(api_key.as_str())
.map_err(FocusError::InvalidHeaderValue)?,
);
}
Expand Down

0 comments on commit 97cb1d6

Please sign in to comment.