-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.hpp
57 lines (49 loc) · 1.51 KB
/
main.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#pragma once
#include "session/session.hpp"
#include "routers/router_base.hpp"
#include <iostream>
#include <attender/attender.hpp>
#include <attender/session/session_manager.hpp>
#include <attender/session/uuid_session_cookie_generator.hpp>
#include <attender/session/authorizer_interface.hpp>
#include <attender/session/basic_authorizer.hpp>
void setupLog();
void setupSignalHandler();
void setupCrashHandler();
void buildDirectoryStructure();
void testLua();
class AuthenticateEveryone : public attender::basic_authorizer
{
std::string realm() const override
{
return "MinIDE_Realm";
}
bool accept_authentication(std::string_view user, std::string_view password) override
{
// we are accepting anyone :3
return true;
}
};
template <typename SessionStoreT, typename ServerT, typename... StoreConstruct>
void installSessionHandler(ServerT& server, std::string const& corsOrigin, StoreConstruct&&... constructionArgs)
{
server.install_session_control
({
std::make_unique <SessionStoreT>(std::forward <StoreConstruct&&>(constructionArgs)...),
std::make_unique <AuthenticateEveryone>(),
"aSID",
true,
[]()
{
attender::cookie c;
c.set_same_site("None");
return c;
}(),
[corsOrigin](auto req, auto res)
{
Routers::enable_cors(req, res, corsOrigin);
},
true,
"/api/authenticate"
});
}