Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Robust and consistent auth header #190

Draft
wants to merge 4 commits into
base: develop
Choose a base branch
from
Draft

Robust and consistent auth header #190

wants to merge 4 commits into from

Conversation

lablans
Copy link
Member

@lablans lablans commented Nov 28, 2024

No description provided.

Copy link
Member

@TKussel TKussel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR deviates from current practice how we use API keys in HTTP headers. I am concerned of maintaining different semantics across our software packages and deviate from the established way only to simplify one CLI arg. Additionally, I see security issues. But that would be your call.

README.md Outdated
@@ -51,7 +51,7 @@ 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 = "ApiKey: XXXX" #Authorization header, in the format "Key: Value"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would advise agains this. The current format AUTHORIZATION: ApiKey XXX follows the RFC 9110 with authorization method ApiKey. Additionally,, this is how Mainzelliste and MainSEL implements it.
If you want to use a non-standard-header, I would advise for x-api-key as recommended by OpenAPI.

src/config.rs Outdated

Some((header_name, header_value))
} else {
return Err(FocusError::ConfigurationError(format!("Missing ':' in auth header value \"{}\"", auth_header)));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a description of the error logic is more useful? Something in the line of "Missing header key (the part before the colon)"?

src/config.rs Outdated
@@ -219,6 +219,25 @@ impl Config {
let client = prepare_reqwest_client(&tls_ca_certificates)?;
dbg!(cli_args.endpoint_url.clone());
dbg!(cli_args.blaze_url.clone());

let auth_header = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not an auth header anymore, but an arbitrary header field, right? We should rename it then.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additinally, this imposes a security risk to be able to send an arbitrary header, potentially overriding exsisting headers if they are already present.

@enola-dkfz
Copy link
Member

This PR provides an invaluable improvement on Focus' architecture and will be an important part of an re-engineering to support multiple endpoints and stores within the same Bridgehead.

However, as it introduces a breaking change for sites that do not run focus inside a Bridgehead, such as EUCAIM providers, we need to coordinate with them regarding the time frame of the merge.

In the meantime I have made the change necessary to avoid confusing Exporter API key with authorization header here: #191

@TKussel
Copy link
Member

TKussel commented Dec 11, 2024

I will convert this PR to a draft until the Focus' re-engineering is better specified

@TKussel TKussel marked this pull request as draft December 11, 2024 08:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants