Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F32281362
D3245.1765266334.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
8 KB
Referenced Files
None
Subscribers
None
D3245.1765266334.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,28 @@
+#pragma once
+
+#include "../_generated/backup.pb.h"
+
+#include <google/protobuf/message.h>
+
+#include <string>
+#include <memory>
+
+namespace comm {
+namespace network {
+namespace auth {
+
+enum class AuthenticationType {
+ PAKE = 1,
+ WALLET = 2,
+};
+
+class AuthenticationHandlerBase {
+public:
+ virtual backup::FullAuthenticationResponseData
+ processRequest(const backup::FullAuthenticationRequestData &request) = 0;
+ virtual AuthenticationType getAuthenticationType() const = 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,34 @@
+#pragma once
+
+#include "AuthenticationHandlerBase.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<AuthenticationHandlerBase> authenticationHandler;
+
+ AuthenticationType getAuthenticationTypeForRequest(
+ const backup::FullAuthenticationRequestData &request) const;
+
+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,47 @@
+#include "AuthenticationManager.h"
+
+#include "PakeAuthenticationHandler.h"
+#include "WalletAuthenticationHandler.h"
+
+namespace comm {
+namespace network {
+namespace auth {
+
+AuthenticationState AuthenticationManager::getState() const {
+ return this->state;
+}
+
+AuthenticationType AuthenticationManager::getAuthenticationTypeForRequest(
+ const backup::FullAuthenticationRequestData &request) const {
+ if (request.has_pakeauthenticationrequestdata()) {
+ return AuthenticationType::PAKE;
+ } else if (request.has_walletauthenticationrequestdata()) {
+ return AuthenticationType::WALLET;
+ }
+ throw std::runtime_error("invalid authentication type detected");
+}
+
+backup::FullAuthenticationResponseData AuthenticationManager::processRequest(
+ const backup::FullAuthenticationRequestData &request) {
+ if (this->authenticationHandler == nullptr) {
+ AuthenticationType authenticationType =
+ this->getAuthenticationTypeForRequest(request);
+ if (authenticationType == AuthenticationType::PAKE) {
+ this->authenticationHandler =
+ std::make_unique<PakeAuthenticationHandler>(authenticationType);
+ } else if (authenticationType == AuthenticationType::WALLET) {
+ this->authenticationHandler =
+ std::make_unique<WalletAuthenticationHandler>(authenticationType);
+ }
+ } else if (
+ this->authenticationHandler->getAuthenticationType() !=
+ this->getAuthenticationTypeForRequest(request)) {
+ throw std::runtime_error("inconsistent authentication detected");
+ }
+
+ return this->authenticationHandler->processRequest(request);
+}
+
+} // 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,24 @@
+#pragma once
+
+#include "AuthenticationHandlerBase.h"
+
+#include <string>
+
+namespace comm {
+namespace network {
+namespace auth {
+
+class PakeAuthenticationHandler : public AuthenticationHandlerBase {
+ const AuthenticationType authenticationType;
+
+public:
+ PakeAuthenticationHandler(AuthenticationType authenticationType);
+
+ backup::FullAuthenticationResponseData
+ processRequest(const backup::FullAuthenticationRequestData &request) override;
+ AuthenticationType getAuthenticationType() const 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,23 @@
+#include "PakeAuthenticationHandler.h"
+
+namespace comm {
+namespace network {
+namespace auth {
+
+PakeAuthenticationHandler::PakeAuthenticationHandler(
+ AuthenticationType authenticationType) : authenticationType(authenticationType) {}
+
+backup::FullAuthenticationResponseData
+PakeAuthenticationHandler::processRequest(
+ const backup::FullAuthenticationRequestData &request) {
+ return backup::FullAuthenticationResponseData();
+}
+
+AuthenticationType
+PakeAuthenticationHandler::getAuthenticationType() const {
+ return this->authenticationType;
+}
+
+} // 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,24 @@
+#pragma once
+
+#include "AuthenticationHandlerBase.h"
+
+#include <string>
+
+namespace comm {
+namespace network {
+namespace auth {
+
+class WalletAuthenticationHandler : public AuthenticationHandlerBase {
+ const AuthenticationType authenticationType;
+
+public:
+ WalletAuthenticationHandler(AuthenticationType authenticationType);
+
+ backup::FullAuthenticationResponseData
+ processRequest(const backup::FullAuthenticationRequestData &request) override;
+ AuthenticationType getAuthenticationType() const 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,24 @@
+#include "WalletAuthenticationHandler.h"
+
+namespace comm {
+namespace network {
+namespace auth {
+
+WalletAuthenticationHandler::WalletAuthenticationHandler(
+ AuthenticationType authenticationType)
+ : authenticationType(authenticationType) {
+}
+
+backup::FullAuthenticationResponseData
+WalletAuthenticationHandler::processRequest(
+ const backup::FullAuthenticationRequestData &request) {
+ return backup::FullAuthenticationResponseData();
+}
+
+AuthenticationType WalletAuthenticationHandler::getAuthenticationType() const {
+ return this->authenticationType;
+}
+
+} // namespace auth
+} // namespace network
+} // namespace comm
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Dec 9, 7:45 AM (11 h, 40 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5853311
Default Alt Text
D3245.1765266334.diff (8 KB)
Attached To
Mode
D3245: [services] Backup - authentication handlers
Attached
Detach File
Event Timeline
Log In to Comment