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