diff options
author | Thomas Keppler <winfr34k@gmail.com> | 2022-12-21 16:23:50 +0100 |
---|---|---|
committer | Ali Mohammad Pur <Ali.mpfard@gmail.com> | 2022-12-26 08:06:21 +0330 |
commit | b5cae5867ae09463326f597a62e88ecafe5cb3a6 (patch) | |
tree | 51b70de0c0a9609dabefe578b08a39b3012d92e8 /Userland/Utilities/pro.cpp | |
parent | de23e7c2d37ba2ca1345e81ca636d7b72d543922 (diff) | |
download | serenity-b5cae5867ae09463326f597a62e88ecafe5cb3a6.zip |
pro: Override authorization with manually set Authorization header
Diffstat (limited to 'Userland/Utilities/pro.cpp')
-rw-r--r-- | Userland/Utilities/pro.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/Userland/Utilities/pro.cpp b/Userland/Utilities/pro.cpp index 0691aeb911..41d2bc634b 100644 --- a/Userland/Utilities/pro.cpp +++ b/Userland/Utilities/pro.cpp @@ -246,11 +246,12 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) auto output_stream = ConditionalOutputFileStream { [&] { return should_save_stream_data; }, stdout }; // https://httpwg.org/specs/rfc9110.html#authentication - if (!credentials.is_empty() && is_http_url) { + auto const has_credentials = !credentials.is_empty(); + auto const has_manual_authorization_header = request_headers.contains("Authorization"); + if (is_http_url && has_credentials && !has_manual_authorization_header) { // 11.2. Authentication Parameters // The authentication scheme is followed by additional information necessary for achieving authentication via // that scheme as (...) or a single sequence of characters capable of holding base64-encoded information. - // FIXME: Prevent overriding manually provided Authorization header auto const encoded_credentials = TRY(encode_base64(credentials.bytes())); auto const authorization = TRY(String::formatted("Basic {}", encoded_credentials)); request_headers.set("Authorization", authorization.to_deprecated_string()); |