add use_internal_session_mechanism and use_internal_loggin_mechanism config options
This commit is contained in:
@@ -475,31 +475,34 @@ Session * SessionManager::PrepareSession()
|
||||
{
|
||||
session = nullptr;
|
||||
|
||||
if( !IsIPBanned() )
|
||||
if( config->use_internal_session_mechanism )
|
||||
{
|
||||
CookieTab::iterator i = cur->request->cookie_tab.find(config->http_session_id_name);
|
||||
|
||||
if( i != cur->request->cookie_tab.end() )
|
||||
if( !IsIPBanned() )
|
||||
{
|
||||
if( !SetSessionFromCookie(i->second) )
|
||||
CookieTab::iterator i = cur->request->cookie_tab.find(config->http_session_id_name);
|
||||
|
||||
if( i != cur->request->cookie_tab.end() )
|
||||
{
|
||||
cur->request->cookie_tab.erase(i);
|
||||
if( !SetSessionFromCookie(i->second) )
|
||||
{
|
||||
cur->request->cookie_tab.erase(i);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( cur->request->function && cur->request->function->need_session )
|
||||
{
|
||||
NoSessionCookieWasSent();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( cur->request->function && cur->request->function->need_session )
|
||||
{
|
||||
NoSessionCookieWasSent();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( !session && cur->request->function && cur->request->function->need_session )
|
||||
{
|
||||
if( !current_ip_ban || !current_ip_ban->IsIPBanned() )
|
||||
if( !session && cur->request->function && cur->request->function->need_session )
|
||||
{
|
||||
CreateSession();
|
||||
if( !current_ip_ban || !current_ip_ban->IsIPBanned() )
|
||||
{
|
||||
CreateSession();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -516,14 +519,17 @@ Session * SessionManager::PrepareSession()
|
||||
|
||||
Session * SessionManager::CheckIfFunctionRequireSession()
|
||||
{
|
||||
if( cur->request->function && cur->request->function->need_session )
|
||||
if( config->use_internal_session_mechanism )
|
||||
{
|
||||
if( session == &temporary_session )
|
||||
if( cur->request->function && cur->request->function->need_session )
|
||||
{
|
||||
if( !current_ip_ban || !current_ip_ban->IsIPBanned() )
|
||||
if( session == &temporary_session )
|
||||
{
|
||||
CreateSession();
|
||||
session->ip_ban = current_ip_ban;
|
||||
if( !current_ip_ban || !current_ip_ban->IsIPBanned() )
|
||||
{
|
||||
CreateSession();
|
||||
session->ip_ban = current_ip_ban;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -652,34 +658,37 @@ void SessionManager::LoadSessions()
|
||||
SessionParser sp;
|
||||
SessionContainer::Iterator i;
|
||||
|
||||
if( !config->session_file.empty() )
|
||||
if( config->use_internal_session_mechanism )
|
||||
{
|
||||
sp.set_dependency(this);
|
||||
|
||||
// sessions will be overwritten (pointers are invalidated)
|
||||
cur->session = &temporary_session;
|
||||
|
||||
sp.SetUsers(&system->users);
|
||||
sp.Parse(config->session_file, session_tab);
|
||||
|
||||
for(i=session_tab.Begin() ; i != session_tab.End() ; ++i)
|
||||
if( !config->session_file.empty() )
|
||||
{
|
||||
i->plugin_data.Resize(plugin->Size());
|
||||
plugin->Call(main_model_connector, &main_log, &(*i), nullptr, nullptr, WINIX_SESSION_CREATED);
|
||||
sp.set_dependency(this);
|
||||
|
||||
/*
|
||||
!! IMPROVE ME
|
||||
we do not add it to the last_container (we don't have IP address stored yet)
|
||||
*/
|
||||
// sessions will be overwritten (pointers are invalidated)
|
||||
cur->session = &temporary_session;
|
||||
|
||||
if( i->puser )
|
||||
plugin->Call(main_model_connector, &main_log, &(*i), nullptr, nullptr, WINIX_USER_LOGGED);
|
||||
sp.SetUsers(&system->users);
|
||||
sp.Parse(config->session_file, session_tab);
|
||||
|
||||
for(i=session_tab.Begin() ; i != session_tab.End() ; ++i)
|
||||
{
|
||||
i->plugin_data.Resize(plugin->Size());
|
||||
plugin->Call(main_model_connector, &main_log, &(*i), nullptr, nullptr, WINIX_SESSION_CREATED);
|
||||
|
||||
/*
|
||||
!! IMPROVE ME
|
||||
we do not add it to the last_container (we don't have IP address stored yet)
|
||||
*/
|
||||
|
||||
if( i->puser )
|
||||
plugin->Call(main_model_connector, &main_log, &(*i), nullptr, nullptr, WINIX_USER_LOGGED);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// FIXME this log is not printed, why?
|
||||
main_log << log1 << "SM: session_file config parameter is empty, not loading sessions" << logend;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// FIXME this log is not printed, why?
|
||||
main_log << log1 << "SM: session_file config parameter is empty, not loading sessions" << logend;
|
||||
}
|
||||
|
||||
cur->session = &temporary_session;
|
||||
@@ -693,6 +702,11 @@ void SessionManager::SaveSessions()
|
||||
{
|
||||
char file_path[WINIX_OS_PATH_SIZE];
|
||||
|
||||
if( !config->use_internal_session_mechanism )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if( config->session_file.empty() )
|
||||
{
|
||||
main_log << log1 << "SM: session_file config parameter is empty, not saving sessions - sessions lost" << logend;
|
||||
|
||||
Reference in New Issue
Block a user