OdbDesignLib
OdbDesign ODB++ Parsing Library
 
Loading...
Searching...
No Matches
RequestAuthenticationBase.cpp
1#include "RequestAuthenticationBase.h"
2#include "macros.h"
3
4using namespace Utils;
5
6namespace 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(crow::status::OK, "Authorized");
20 }
21 else if (m_disableAuthentication)
22 {
23 // 200 Authorized!
24 return crow::response(crow::status::OK, "Authorized");
25 }
26 else
27 {
28 return crow::response(crow::status::UNAUTHORIZED, "Unauthorized");
29 }
30 }
31}