Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3527759
D3245.id9835.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
6 KB
Referenced Files
None
Subscribers
None
D3245.id9835.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,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 <string>
+
+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 <memory>
+
+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> pakeAuthenticationHandler;
+ std::unique_ptr<WalletAuthenticationHandler> 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 <string>
+
+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 <string>
+
+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
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Dec 25, 6:34 AM (54 m, 37 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2701845
Default Alt Text
D3245.id9835.diff (6 KB)
Attached To
Mode
D3245: [services] Backup - authentication handlers
Attached
Detach File
Event Timeline
Log In to Comment