-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
86 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,27 @@ | ||
#pragma once | ||
|
||
#include "IRequestAuthentication.h" | ||
#include "RequestAuthenticationBase.h" | ||
#include "../odbdesign_export.h" | ||
|
||
namespace Odb::Lib::App | ||
{ | ||
class ODBDESIGN_EXPORT BasicRequestAuthentication : public IRequestAuthentication | ||
class ODBDESIGN_EXPORT BasicRequestAuthentication : public RequestAuthenticationBase | ||
{ | ||
public: | ||
//BasicRequestAuthentication() | ||
//{ | ||
//} | ||
BasicRequestAuthentication(bool disableAuthentication); | ||
|
||
// Inherited via IRequestAuthentication | ||
// Inherited via RequestAuthenticationBase | ||
crow::response AuthenticateRequest(const crow::request& req) override; | ||
|
||
private: | ||
|
||
const inline static char AUTHORIZATION_HEADER_NAME[] = "Authorization"; | ||
|
||
crow::response VerifyCredentials(const std::string& username, const std::string& password); | ||
|
||
const inline static char USERNAME_ENV_NAME[] = "ODBDESIGN_SERVER_REQUEST_USERNAME"; | ||
const inline static char PASSWORD_ENV_NAME[] = "ODBDESIGN_SERVER_REQUEST_PASSWORD"; | ||
|
||
|
||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#include "RequestAuthenticationBase.h" | ||
#include "macros.h" | ||
|
||
using namespace Utils; | ||
|
||
namespace Odb::Lib::App | ||
{ | ||
RequestAuthenticationBase::RequestAuthenticationBase(bool disableAuthentication) | ||
: m_disableAuthentication(disableAuthentication) | ||
{ | ||
} | ||
|
||
crow::response RequestAuthenticationBase::AuthenticateRequest(const crow::request& req) | ||
{ | ||
// if running debug build AND in Local environment, bypass authentication | ||
if (IsDebug() && IsLocal()) | ||
{ | ||
// 200 Authorized! | ||
return crow::response(200, "Authorized"); | ||
} | ||
else if (m_disableAuthentication) | ||
{ | ||
// 200 Authorized! | ||
return crow::response(200, "Authorized"); | ||
} | ||
else | ||
{ | ||
return crow::response(401, "Unauthorized"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters