Commit 8c5626ef authored by Sophie Wenzel-Teuber's avatar Sophie Wenzel-Teuber
Browse files

Remove Authorisation for purpose of MVP with copyTool

This adds the CMake variable FIPHOBOSERVER_DISABLE_AUTHORISATION to disable the authentication

Changelog:
* Add option and variable to CMake
* Add ifndef pragmas to request handlers
* Update Readme
parent 499566af
Pipeline #1668 canceled with stages
......@@ -20,6 +20,11 @@ option(
"build FiPhoboServer Documentation. Depends on Doxygen."
OFF
)
option(
FIPHOBOSERVER_DISABLE_AUTHORISATION
"build FiPhoboServer with AWS authorisation disabled. Default is enabled"
OFF
)
add_subdirectory(src)
......
......@@ -65,6 +65,7 @@ Option | Effect
Option | Effect
------ | ------
`-DFIPHOBOSERVER_BUILD_TESTS=...` | Set to `ON` to build FIPhoboServer tests and enable the `make test` target, or `OFF` to skip (Default `OFF`).
`-DFIPHOBOSERVER_DISABLE_AUTHORISATION=...` | Set to `ON` to disable AWS V4 authorisation (= letting everything through), or `OFF` to authorise requests (Default `OFF`).
`-DFIPHOBOSERVER_BUILD_DOCUMENTATION=...` | Set to `ON` to build FIPhoboServer Doxygen documentation, or `OFF` to skip (Default `OFF`).
`-DCUSTOM_DOCU_PATH=...` | Set to the path to the `src` folder in [DoxygenXMLParser](https://git.ichec.ie/sophie.wenzel-teuber/doxygen-xml-parser) to create the Markdown output from the Doxygen XML, that can also be found [here](doc/Markdown/fiphoboserver) or don't set to skip (Default `not set`).
......
......@@ -9,6 +9,11 @@ add_library(
unsupported_request_handler.cc
)
if(FIPHOBOSERVER_DISABLE_AUTHORISATION)
message("Disabling AWS V4 authorisation for the server")
set_target_properties(server PROPERTIES COMPILE_DEFINITIONS "NO_AUTHORISATION")
endif(FIPHOBOSERVER_DISABLE_AUTHORISATION)
#SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -O1")
target_link_libraries(server PUBLIC proxygen::proxygen)
target_link_libraries(server PUBLIC stream)
......
......@@ -33,6 +33,7 @@ void GetRequestHandler::onRequest(
m_s3_header.set_headers(std::move(headers));
// m_s3_header.print_all_headers();
#ifndef NO_AUTHORISATION
s3_utilities::S3_authorisation auth;
if (auth.authorise(m_s3_header)
!= s3_utilities::Authorisation_status::valid) {
......@@ -45,6 +46,8 @@ void GetRequestHandler::onRequest(
.sendWithEOM();
return;
}
#endif
try {
/* Send meta data to backend through the stream */
......
......@@ -31,6 +31,7 @@ void GetmdRequestHandler::onRequest(
m_s3_header.set_headers(std::move(headers));
// m_s3_header.print_all_headers();
#ifndef NO_AUTHORISATION
s3_utilities::S3_authorisation auth;
if (auth.authorise(m_s3_header)
!= s3_utilities::Authorisation_status::valid) {
......@@ -43,6 +44,8 @@ void GetmdRequestHandler::onRequest(
.sendWithEOM();
return;
}
#endif
try {
/* Get meta data from backend through the stream */
......
......@@ -29,6 +29,7 @@ void PutRequestHandler::onRequest(
m_s3_header.set_headers(std::move(headers));
// m_s3_header.print_all_headers();
#ifndef NO_AUTHORISATION
if (m_auth.authorise(m_s3_header)
!= s3_utilities::Authorisation_status::waiting_for_payload) {
......@@ -41,6 +42,7 @@ void PutRequestHandler::onRequest(
m_stop_processing = true;
return;
}
#endif
if (m_s3_header.is_bucket_only_request()) {
/*
......@@ -85,10 +87,13 @@ void PutRequestHandler::onBody(std::unique_ptr<folly::IOBuf> body) noexcept
}
try {
#ifndef NO_AUTHORISATION
// Add body as string to authentication object as payload
std::string body_as_string = std::string(
reinterpret_cast<const char*>(body->data()), body->length());
m_auth.add_chunk(body_as_string);
#endif
/* Hand message body over to stream for PUT operation */
m_stream->put(std::move(body->data()), std::move(body->length()));
......@@ -114,6 +119,7 @@ void PutRequestHandler::onEOM() noexcept
return;
}
#ifndef NO_AUTHORISATION
if (m_auth.authorise(m_s3_header)
!= s3_utilities::Authorisation_status::valid) {
// TODO: Delete object from phobos or revert put! (Issue #45)
......@@ -126,22 +132,20 @@ void PutRequestHandler::onEOM() noexcept
return;
}
else {
try {
/* Tell stream it's time to clean up */
m_stream->finish_io();
}
catch (const FIPhoboServerException& ex) {
std::cerr << "Caught an exception in finish put: " << ex.what()
<< '\n';
s3_utilities::s3_error_info error =
s3_utilities::create_s3_error(ex.get_inner_error());
proxygen::ResponseBuilder(downstream_)
.status(error.https_error_code, error.https_error_identifier)
.body(error.get_xml(m_s3_header.get_key()))
.sendWithEOM();
return;
}
#endif
try {
/* Tell stream it's time to clean up */
m_stream->finish_io();
}
catch (const FIPhoboServerException& ex) {
std::cerr << "Caught an exception in finish put: " << ex.what() << '\n';
s3_utilities::s3_error_info error =
s3_utilities::create_s3_error(ex.get_inner_error());
proxygen::ResponseBuilder(downstream_)
.status(error.https_error_code, error.https_error_identifier)
.body(error.get_xml(m_s3_header.get_key()))
.sendWithEOM();
return;
}
proxygen::ResponseBuilder(downstream_).status(200, "OK").sendWithEOM();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment