Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F32375652
D3245.1765328182.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
6 KB
Referenced Files
None
Subscribers
None
D3245.1765328182.diff
View Options
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,8 @@
include_directories(
./src
./src/DatabaseEntities
+ ./src/Authentication
+ ./src/Errors
./_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 <string>
+
+namespace comm {
+namespace network {
+namespace crypto {
+
+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 crypto
+} // 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 <memory>
+
+namespace comm {
+namespace network {
+namespace crypto {
+
+enum class AuthenticationState {
+ IN_PROGRESS = 1,
+ SUCCESS = 2,
+ FAIL = 3,
+};
+
+class AuthenticationManager {
+ AuthenticationState state = AuthenticationState::IN_PROGRESS;
+ std::unique_ptr<PakeAuthenticationHandler> pakeAuthenticationHandler;
+ std::unique_ptr<WalletAuthenticationHandler> walletAuthenticationHandler;
+
+public:
+ AuthenticationState getState() const;
+ backup::FullAuthenticationResponseData
+ processRequest(const backup::FullAuthenticationRequestData &request);
+};
+
+} // namespace crypto
+} // 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,31 @@
+#include "AuthenticationManager.h"
+
+#include "AuthenticationError.h"
+
+namespace comm {
+namespace network {
+namespace crypto {
+
+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 AuthenticationError
+ 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 crypto
+} // 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 <string>
+
+namespace comm {
+namespace network {
+namespace crypto {
+
+class PakeAuthenticationHandler : public AuthenticationHandlerBase {
+public:
+ std::string processRequest(const std::string &data) override;
+};
+
+} // namespace crypto
+} // 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 crypto {
+
+std::string PakeAuthenticationHandler::processRequest(const std::string &data) {
+ return "";
+}
+
+} // namespace crypto
+} // 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 <string>
+
+namespace comm {
+namespace network {
+namespace crypto {
+
+class WalletAuthenticationHandler : public AuthenticationHandlerBase {
+public:
+ std::string processRequest(const std::string &data) override;
+};
+
+} // namespace crypto
+} // 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 crypto {
+
+std::string
+WalletAuthenticationHandler::processRequest(const std::string &data) {
+ return "";
+}
+
+} // namespace crypto
+} // namespace network
+} // namespace comm
diff --git a/services/backup/docker-server/contents/server/src/Errors/AuthenticationError.h b/services/backup/docker-server/contents/server/src/Errors/AuthenticationError.h
new file mode 100644
--- /dev/null
+++ b/services/backup/docker-server/contents/server/src/Errors/AuthenticationError.h
@@ -0,0 +1,13 @@
+#pragma once
+
+namespace comm {
+namespace network {
+
+struct AuthenticationError : public std::exception {
+ const char *what() const throw() {
+ return "connection ended";
+ }
+};
+
+} // namespace network
+} // namespace comm
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Dec 10, 12:56 AM (17 h, 4 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5859455
Default Alt Text
D3245.1765328182.diff (6 KB)
Attached To
Mode
D3245: [services] Backup - authentication handlers
Attached
Detach File
Event Timeline
Log In to Comment