OdbDesignLib
OdbDesign ODB++ Parsing Library
RequestAuthenticationBase.cpp
1 #include "RequestAuthenticationBase.h"
2 #include "macros.h"
3 
4 using namespace Utils;
5 
6 namespace Odb::Lib::App
7 {
8  RequestAuthenticationBase::RequestAuthenticationBase(bool disableAuthentication)
9  : m_disableAuthentication(disableAuthentication)
10  {
11  }
12 
13  crow::response RequestAuthenticationBase::AuthenticateRequest(const crow::request& req)
14  {
15  // if running debug build AND in Local environment, bypass authentication
16  if (IsDebug() && IsLocal())
17  {
18  // 200 Authorized!
19  return crow::response(200, "Authorized");
20  }
21  else if (m_disableAuthentication)
22  {
23  // 200 Authorized!
24  return crow::response(200, "Authorized");
25  }
26  else
27  {
28  return crow::response(401, "Unauthorized");
29  }
30  }
31 }