diff options
author | Ed Tanous <edtanous@google.com> | 2022-03-25 04:20:45 +0300 |
---|---|---|
committer | Ed Tanous <ed@tanous.net> | 2022-04-05 21:52:20 +0300 |
commit | 142ec9aeb70c23a1aa98aa90d472ff11a76529ee (patch) | |
tree | 45eee07091c0654cfcc2328dd4bd4e6ae790d48b /redfish-core/include/query.hpp | |
parent | 7cf436c913a109c0d3ebf7e696970966500bc6b6 (diff) | |
download | bmcweb-142ec9aeb70c23a1aa98aa90d472ff11a76529ee.tar.xz |
Implement odata-version checks
The redfish protocol validator is a cruel.... cruel test. In it, it
attempts to send odata-version headers that are not supported by the
spec. bmcweb has never had a use for those headers, and they are
optional to send, so bmcweb ignored them. This patchset fixes that.
The exact wording of the standard is in the patch.
Tested:
curl --insecure --user root:0penBmc https://192.168.7.2/redfish/v1
Returns service root
curl --insecure --user root:0penBmc -H "Odata-version: 4.0" https://192.168.7.2/redfish/v1
returns service root
curl --insecure --user root:0penBmc -H "Odata-version: 4.1" https://192.168.7.2/redfish/v1
returns precondition failed message from base registry, and 501 code.
Redfish protocol validator now shows REQ_HEADERS_ODATA_VERSION test
passing.
Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: I7d2f4bd9f6b7f03655d7e169ee20f45f9aaa73e3
Diffstat (limited to 'redfish-core/include/query.hpp')
-rw-r--r-- | redfish-core/include/query.hpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/redfish-core/include/query.hpp b/redfish-core/include/query.hpp index b06278b472..7db370d9fb 100644 --- a/redfish-core/include/query.hpp +++ b/redfish-core/include/query.hpp @@ -11,6 +11,19 @@ namespace redfish const crow::Request& req, crow::Response& res) { + BMCWEB_LOG_DEBUG << "setup redfish route"; + + // Section 7.4 of the redfish spec "Redfish Services shall process the + // [OData-Version header] in the following table as defined by the HTTP 1.1 + // specification..." + // Required to pass redfish-protocol-validator REQ_HEADERS_ODATA_VERSION + std::string_view odataHeader = req.getHeaderValue("OData-Version"); + if (!odataHeader.empty() && odataHeader != "4.0") + { + messages::preconditionFailed(res); + return false; + } + // If query parameters aren't enabled, do nothing. if constexpr (!bmcwebInsecureEnableQueryParams) { |