add use_internal_session_mechanism and use_internal_loggin_mechanism config options
This commit is contained in:
parent
c85a724fec
commit
9e6a5b2d37
|
@ -191,6 +191,9 @@ void Config::AssignValues()
|
|||
templates_request_status = Text(L"templates_request_status", L"request_status.html");
|
||||
template_only_root_use_template_fun = Bool(L"template_only_root_use_template_fun", false);
|
||||
|
||||
use_internal_session_mechanism = Bool(L"use_internal_session_mechanism", true);
|
||||
use_internal_loggin_mechanism = Bool(L"use_internal_loggin_mechanism", true);
|
||||
|
||||
http_session_id_name = Text(L"http_session_id_name", L"session_id");
|
||||
db_conn_string = Text(L"db_conn_string");
|
||||
db_host = Text(L"db_host");
|
||||
|
|
|
@ -267,6 +267,18 @@ public:
|
|||
// if a migration fails then stop winix
|
||||
bool db_stop_if_migration_fails;
|
||||
|
||||
// use internal session mechanism
|
||||
// default: true
|
||||
// if false then we do not load/save and create internal sessions
|
||||
// but there always be the temporary session object for a request
|
||||
// also we do not load 'who' winix function
|
||||
bool use_internal_session_mechanism;
|
||||
|
||||
// use internal loggin mechanism
|
||||
// default: true
|
||||
// if false then we do not load 'login' and 'logout' winix functions
|
||||
// and the system will not allow to login through its api
|
||||
bool use_internal_loggin_mechanism;
|
||||
|
||||
// the name of the cookie which has the session identifier
|
||||
std::wstring http_session_id_name;
|
||||
|
|
|
@ -475,6 +475,8 @@ Session * SessionManager::PrepareSession()
|
|||
{
|
||||
session = nullptr;
|
||||
|
||||
if( config->use_internal_session_mechanism )
|
||||
{
|
||||
if( !IsIPBanned() )
|
||||
{
|
||||
CookieTab::iterator i = cur->request->cookie_tab.find(config->http_session_id_name);
|
||||
|
@ -502,6 +504,7 @@ Session * SessionManager::PrepareSession()
|
|||
CreateSession();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( !session )
|
||||
{
|
||||
|
@ -516,6 +519,8 @@ Session * SessionManager::PrepareSession()
|
|||
|
||||
Session * SessionManager::CheckIfFunctionRequireSession()
|
||||
{
|
||||
if( config->use_internal_session_mechanism )
|
||||
{
|
||||
if( cur->request->function && cur->request->function->need_session )
|
||||
{
|
||||
if( session == &temporary_session )
|
||||
|
@ -527,6 +532,7 @@ Session * SessionManager::CheckIfFunctionRequireSession()
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return session;
|
||||
}
|
||||
|
@ -652,6 +658,8 @@ void SessionManager::LoadSessions()
|
|||
SessionParser sp;
|
||||
SessionContainer::Iterator i;
|
||||
|
||||
if( config->use_internal_session_mechanism )
|
||||
{
|
||||
if( !config->session_file.empty() )
|
||||
{
|
||||
sp.set_dependency(this);
|
||||
|
@ -681,6 +689,7 @@ SessionContainer::Iterator i;
|
|||
// 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;
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008-2021, Tomasz Sowa
|
||||
* Copyright (c) 2008-2022, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -264,6 +264,11 @@ return puser;
|
|||
|
||||
bool Users::LoginUser(long user_id, bool remember_me, bool use_ses_log)
|
||||
{
|
||||
Config * config = get_config();
|
||||
|
||||
if( !config || !config->use_internal_loggin_mechanism )
|
||||
return false;
|
||||
|
||||
if( !LoginUserCheckSession(use_ses_log) )
|
||||
return false;
|
||||
|
||||
|
@ -343,6 +348,10 @@ return how_many;
|
|||
|
||||
void Users::LogoutCurrentUser()
|
||||
{
|
||||
Config * config = get_config();
|
||||
|
||||
if( config && config->use_internal_loggin_mechanism )
|
||||
{
|
||||
Log * log = get_logger();
|
||||
Session * session = get_session();
|
||||
|
||||
|
@ -363,6 +372,7 @@ void Users::LogoutCurrentUser()
|
|||
|
||||
session->puser = 0;
|
||||
session->remember_me = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -244,8 +244,13 @@ void Functions::CreateFunctions()
|
|||
Add(fun_imgcrop);
|
||||
Add(fun_last);
|
||||
Add(fun_locale);
|
||||
|
||||
if( config->use_internal_loggin_mechanism )
|
||||
{
|
||||
Add(fun_login);
|
||||
Add(fun_logout);
|
||||
}
|
||||
|
||||
Add(fun_ln);
|
||||
Add(fun_ls);
|
||||
Add(fun_ipban);
|
||||
|
@ -273,7 +278,12 @@ void Functions::CreateFunctions()
|
|||
Add(fun_uname);
|
||||
Add(fun_upload);
|
||||
Add(fun_uptime);
|
||||
|
||||
if( config->use_internal_session_mechanism )
|
||||
{
|
||||
Add(fun_who);
|
||||
}
|
||||
|
||||
Add(fun_vim);
|
||||
|
||||
plugin->Call(WINIX_CREATE_FUNCTIONS);
|
||||
|
|
Loading…
Reference in New Issue