diff --git a/services/backup/docker-server/contents/server/CMakeLists.txt b/services/backup/docker-server/contents/server/CMakeLists.txt --- a/services/backup/docker-server/contents/server/CMakeLists.txt +++ b/services/backup/docker-server/contents/server/CMakeLists.txt @@ -51,6 +51,7 @@ include_directories( ./src ./src/DatabaseEntities + ./src/Authentication ./_generated ${FOLLY_INCLUDES} ./lib/double-conversion diff --git a/services/backup/docker-server/contents/server/src/Authentication/AuthenticationHandlerBase.h b/services/backup/docker-server/contents/server/src/Authentication/AuthenticationHandlerBase.h new file mode 100644 --- /dev/null +++ b/services/backup/docker-server/contents/server/src/Authentication/AuthenticationHandlerBase.h @@ -0,0 +1,21 @@ +#pragma once + +#include + +namespace comm { +namespace network { +namespace auth { + +class AuthenticationHandlerBase { +public: + /** + * this function should be called repeatedly, it receives data from client + * and returns what should be sent back to the client + * once an empty string is returned we should verify the state + */ + virtual std::string processRequest(const std::string &data) = 0; +}; + +} // namespace auth +} // namespace network +} // namespace comm diff --git a/services/backup/docker-server/contents/server/src/Authentication/AuthenticationManager.h b/services/backup/docker-server/contents/server/src/Authentication/AuthenticationManager.h new file mode 100644 --- /dev/null +++ b/services/backup/docker-server/contents/server/src/Authentication/AuthenticationManager.h @@ -0,0 +1,33 @@ +#pragma once + +#include "PakeAuthenticationHandler.h" +#include "WalletAuthenticationHandler.h" + +#include "../_generated/backup.pb.h" + +#include + +namespace comm { +namespace network { +namespace auth { + +enum class AuthenticationState { + IN_PROGRESS = 1, + SUCCESS = 2, + FAIL = 3, +}; + +class AuthenticationManager { + AuthenticationState state = AuthenticationState::IN_PROGRESS; + std::unique_ptr pakeAuthenticationHandler; + std::unique_ptr walletAuthenticationHandler; + +public: + AuthenticationState getState() const; + backup::FullAuthenticationResponseData + processRequest(const backup::FullAuthenticationRequestData &request); +}; + +} // namespace auth +} // namespace network +} // namespace comm diff --git a/services/backup/docker-server/contents/server/src/Authentication/AuthenticationManager.cpp b/services/backup/docker-server/contents/server/src/Authentication/AuthenticationManager.cpp new file mode 100644 --- /dev/null +++ b/services/backup/docker-server/contents/server/src/Authentication/AuthenticationManager.cpp @@ -0,0 +1,29 @@ +#include "AuthenticationManager.h" + +namespace comm { +namespace network { +namespace auth { + +AuthenticationState AuthenticationManager::getState() const { + return this->state; +} + +backup::FullAuthenticationResponseData AuthenticationManager::processRequest( + const backup::FullAuthenticationRequestData &request) { + // TODO auth logic + // in case of any auth-specific failure, just throw runtime error + if (request.has_pakeauthenticationrequestdata()) { + // operations on this->pakeAuthenticationHandler which will have + // its own state + } else if (request.has_walletauthenticationrequestdata()) { + // operations on this->walletAuthenticationHandler which will have + // its own state + } + // mock success for now + this->state = AuthenticationState::SUCCESS; + return backup::FullAuthenticationResponseData(); +} + +} // namespace auth +} // namespace network +} // namespace comm diff --git a/services/backup/docker-server/contents/server/src/Authentication/PakeAuthenticationHandler.h b/services/backup/docker-server/contents/server/src/Authentication/PakeAuthenticationHandler.h new file mode 100644 --- /dev/null +++ b/services/backup/docker-server/contents/server/src/Authentication/PakeAuthenticationHandler.h @@ -0,0 +1,18 @@ +#pragma once + +#include "AuthenticationHandlerBase.h" + +#include + +namespace comm { +namespace network { +namespace auth { + +class PakeAuthenticationHandler : public AuthenticationHandlerBase { +public: + std::string processRequest(const std::string &data) override; +}; + +} // namespace auth +} // namespace network +} // namespace comm diff --git a/services/backup/docker-server/contents/server/src/Authentication/PakeAuthenticationHandler.cpp b/services/backup/docker-server/contents/server/src/Authentication/PakeAuthenticationHandler.cpp new file mode 100644 --- /dev/null +++ b/services/backup/docker-server/contents/server/src/Authentication/PakeAuthenticationHandler.cpp @@ -0,0 +1,13 @@ +#include "PakeAuthenticationHandler.h" + +namespace comm { +namespace network { +namespace auth { + +std::string PakeAuthenticationHandler::processRequest(const std::string &data) { + return ""; +} + +} // namespace auth +} // namespace network +} // namespace comm diff --git a/services/backup/docker-server/contents/server/src/Authentication/WalletAuthenticationHandler.h b/services/backup/docker-server/contents/server/src/Authentication/WalletAuthenticationHandler.h new file mode 100644 --- /dev/null +++ b/services/backup/docker-server/contents/server/src/Authentication/WalletAuthenticationHandler.h @@ -0,0 +1,18 @@ +#pragma once + +#include "AuthenticationHandlerBase.h" + +#include + +namespace comm { +namespace network { +namespace auth { + +class WalletAuthenticationHandler : public AuthenticationHandlerBase { +public: + std::string processRequest(const std::string &data) override; +}; + +} // namespace auth +} // namespace network +} // namespace comm diff --git a/services/backup/docker-server/contents/server/src/Authentication/WalletAuthenticationHandler.cpp b/services/backup/docker-server/contents/server/src/Authentication/WalletAuthenticationHandler.cpp new file mode 100644 --- /dev/null +++ b/services/backup/docker-server/contents/server/src/Authentication/WalletAuthenticationHandler.cpp @@ -0,0 +1,14 @@ +#include "WalletAuthenticationHandler.h" + +namespace comm { +namespace network { +namespace auth { + +std::string +WalletAuthenticationHandler::processRequest(const std::string &data) { + return ""; +} + +} // namespace auth +} // namespace network +} // namespace comm