2016-10-15 19:57:04 +02:00
<!DOCTYPE html>
< html lang = "en" dir = "ltr" >
< head >
< meta charset = "utf-8" / >
< title > documentation:2.0:sqlsessionbackend< / title >
< meta name = "generator" content = "DokuWiki" / >
2019-06-28 16:53:45 +02:00
< meta name = "robots" content = "noindex,nofollow" / >
2016-10-15 19:57:04 +02:00
< meta name = "keywords" content = "documentation,2.0,sqlsessionbackend" / >
< link rel = "search" type = "application/opensearchdescription+xml" href = "lib/exe/opensearch.html" title = "LemonLDAP::NG" / >
< link rel = "start" href = "sqlsessionbackend.html" / >
< link rel = "contents" href = "sqlsessionbackend.html" title = "Sitemap" / >
< link rel = "stylesheet" type = "text/css" href = "lib/exe/css.php.t.bootstrap3.css" / >
2017-02-07 17:35:26 +01:00
<!-- //if:usedebianlibs
< link rel = "stylesheet" type = "text/css" href = "/javascript/bootstrap/css/bootstrap.min.css" / >
//elsif:useexternallibs
< link rel = "stylesheet" type = "text/css" href = "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" > < / script >
//elsif:cssminified
< link rel = "stylesheet" type = "text/css" href = "/static/bwr/bootstrap/dist/css/bootstrap.min.css" / >
//else -->
< link rel = "stylesheet" type = "text/css" href = "/static/bwr/bootstrap/dist/css/bootstrap.css" / >
<!-- //endif -->
2016-10-15 19:57:04 +02:00
< script type = "text/javascript" > / * < ! [ C D A T A [ * / v a r N S = ' d o c u m e n t a t i o n : 2 . 0 ' ; v a r J S I N F O = { " i d " : " d o c u m e n t a t i o n : 2 . 0 : s q l s e s s i o n b a c k e n d " , " n a m e s p a c e " : " d o c u m e n t a t i o n : 2 . 0 " } ;
/*!]]>*/< / script >
< script type = "text/javascript" charset = "utf-8" src = "lib/exe/js.php.t.bootstrap3.js" > < / script >
2017-02-07 17:35:26 +01:00
<!-- //if:usedebianlibs
< script type = "text/javascript" src = "/javascript/jquery/jquery.min.js" > < / script >
//elsif:useexternallibs
< script type = "text/javascript" src = "http://code.jquery.com/jquery-2.2.0.min.js" > < / script >
//elsif:jsminified
< script type = "text/javascript" src = "/static/bwr/jquery/dist/jquery.min.js" > < / script >
//else -->
< script type = "text/javascript" src = "/static/bwr/jquery/dist/jquery.js" > < / script >
<!-- //endif -->
<!-- //if:usedebianlibs
< script type = "text/javascript" src = "/javascript/jquery-ui/jquery-ui.min.js" > < / script >
//elsif:useexternallibs
< script type = "text/javascript" src = "http://code.jquery.com/ui/1.10.4/jquery-ui.min.js" > < / script >
//elsif:jsminified
2018-03-08 13:29:31 +01:00
< script type = "text/javascript" src = "/static/bwr/jquery-ui/jquery-ui.min.js" > < / script >
2017-02-07 17:35:26 +01:00
//else -->
2018-03-08 13:29:31 +01:00
< script type = "text/javascript" src = "/static/bwr/jquery-ui/jquery-ui.js" > < / script >
2017-02-07 17:35:26 +01:00
<!-- //endif -->
2016-10-15 19:57:04 +02:00
< / head >
< body >
< div class = "dokuwiki export container" >
<!-- TOC START -->
< div id = "dw__toc" >
< h3 class = "toggle" > Table of Contents< / h3 >
< div >
< ul class = "toc" >
< li class = "level1" > < div class = "li" > < a href = "#setup" > Setup< / a > < / div >
< ul class = "toc" >
< li class = "level2" > < div class = "li" > < a href = "#prepare_the_database" > Prepare the database< / a > < / div >
< ul class = "toc" >
< li class = "level3" > < div class = "li" > < a href = "#mysql" > MySQL< / a > < / div > < / li >
< li class = "level3" > < div class = "li" > < a href = "#postgresql" > PostgreSQL< / a > < / div > < / li >
< / ul >
< / li >
2017-08-30 18:47:22 +02:00
< li class = "level2" > < div class = "li" > < a href = "#manager" > Manager< / a > < / div >
< ul class = "toc" >
< li class = "level3" > < div class = "li" > < a href = "#utf8_support" > UTF8 support< / a > < / div > < / li >
< / ul >
< / li >
2016-10-15 19:57:04 +02:00
< / ul >
< / li >
< li class = "level1" > < div class = "li" > < a href = "#security" > Security< / a > < / div > < / li >
< / ul >
< / div >
< / div >
<!-- TOC END -->
< h1 class = "sectionedit1" id = "sql_session_backend" > SQL session backend< / h1 >
< div class = "level1" >
< p >
SQL session backend can be used with many SQL databases such as:
< / p >
< ul >
2018-11-26 14:15:43 +01:00
< li class = "level1" > < div class = "li" > < a href = "https://metacpan.org/pod/Apache::Session::MySQL" class = "urlextern" title = "https://metacpan.org/pod/Apache::Session::MySQL" rel = "nofollow" > MariaDB / MySQL< / a > < / div >
2016-10-15 19:57:04 +02:00
< / li >
2018-11-26 14:15:43 +01:00
< li class = "level1" > < div class = "li" > < a href = "https://metacpan.org/pod/Apache::Session::Postgres" class = "urlextern" title = "https://metacpan.org/pod/Apache::Session::Postgres" rel = "nofollow" > PostgreSQL< / a > < / div >
2016-10-15 19:57:04 +02:00
< / li >
2018-11-26 14:15:43 +01:00
< li class = "level1" > < div class = "li" > < a href = "https://metacpan.org/pod/Apache::Session::Oracle" class = "urlextern" title = "https://metacpan.org/pod/Apache::Session::Oracle" rel = "nofollow" > Oracle< / a > < / div >
2016-10-15 19:57:04 +02:00
< / li >
2018-11-26 14:15:43 +01:00
< li class = "level1" > < div class = "li" > < a href = "https://metacpan.org/pod/Apache::Session::Informix" class = "urlextern" title = "https://metacpan.org/pod/Apache::Session::Informix" rel = "nofollow" > Informix< / a > < / div >
2016-10-15 19:57:04 +02:00
< / li >
2018-11-26 14:15:43 +01:00
< li class = "level1" > < div class = "li" > < a href = "https://metacpan.org/pod/Apache::Session::Sybase" class = "urlextern" title = "https://metacpan.org/pod/Apache::Session::Sybase" rel = "nofollow" > Sybase< / a > < / div >
2016-10-15 19:57:04 +02:00
< / li >
2019-02-12 17:32:02 +01:00
< li class = "level1" > < div class = "li" > ....< / div >
2016-10-15 19:57:04 +02:00
< / li >
< / ul >
< / div >
2018-11-26 14:15:43 +01:00
<!-- EDIT1 SECTION "SQL session backend" [1 - 448] -->
2016-10-15 19:57:04 +02:00
< h2 class = "sectionedit2" id = "setup" > Setup< / h2 >
< div class = "level2" >
< / div >
2018-11-26 14:15:43 +01:00
<!-- EDIT2 SECTION "Setup" [449 - 467] -->
2016-10-15 19:57:04 +02:00
< h3 class = "sectionedit3" id = "prepare_the_database" > Prepare the database< / h3 >
< div class = "level3" >
< p >
Your database must have a specific table to host sessions. Here are some examples for main databases servers.
< / p >
< div class = "noteimportant" > If your database doesn' t accept UTF-8 characters in ' text' field, use ' blob' instead of ' text' .
< / div >
< / div >
< h4 id = "mysql" > MySQL< / h4 >
< div class = "level4" >
< p >
Create a database if necessary:
< / p >
2019-06-28 16:53:45 +02:00
< pre class = "code" > mysqladmin create lemonldap-ng< / pre >
2016-10-15 19:57:04 +02:00
< p >
Create sessions table:
< / p >
< pre class = "code file sql" > < span class = "kw1" > CREATE< / span > < span class = "kw1" > TABLE< / span > sessions < span class = "br0" > ( < / span >
id < span class = "kw1" > CHAR< / span > < span class = "br0" > ( < / span > < span class = "nu0" > 32< / span > < span class = "br0" > ) < / span > < span class = "kw1" > NOT< / span > < span class = "kw1" > NULL< / span > < span class = "kw1" > PRIMARY< / span > < span class = "kw1" > KEY< / span > < span class = "sy0" > ,< / span >
a_session text
< span class = "br0" > ) < / span > ;< / pre >
2017-04-04 20:05:25 +02:00
< div class = "noteimportant" > Change < code > char(32)< / code > by < code > varchar(64)< / code > if you use the now recommended SHA256 hash algorithm. See < a href = "documentation/latest/sessions.html" class = "wikilink1" title = "documentation:latest:sessions" > Sessions< / a > for more details
2016-10-15 19:57:04 +02:00
< / div > < div class = "notetip" > You can change table name < code > sessions< / code > to whatever you want, just adapt the parameter < code > TableName< / code > in module options.
2018-11-26 14:15:43 +01:00
< / div > < div class = "noteimportant" > For a better UTF-8 support, use < a href = "https://metacpan.org/pod/DBD::MariaDB" class = "urlextern" title = "https://metacpan.org/pod/DBD::MariaDB" rel = "nofollow" > DBD::MariaDB< / a > with Apache::Session*::MySQL instead of DBD::mysql
2016-10-15 19:57:04 +02:00
< / div >
< / div >
< h4 id = "postgresql" > PostgreSQL< / h4 >
< div class = "level4" >
< p >
Create user and role:
< / p >
< pre class = "code" > su - postgres
createuser lemonldap-ng -P< / pre >
< pre class = "code" > Entrez le mot de passe pour le nouveau rôle : < PASSWORD>
Entrez-le de nouveau : < PASSWORD>
Le nouveau rôle est-il un super-utilisateur ? (o/n) n
Le nouveau rôle doit-il être autorisé à créer des bases de données ? (o/n) n
Le nouveau rôle doit-il être autorisé à créer de nouveaux rôles ? (o/n) n< / pre >
< p >
Create database:
< / p >
< pre class = "code" > createdb -O lemonldap-ng lemonldap-ng< / pre >
< p >
Create table:
< / p >
< pre class = "code" > psql -h 127.0.0.1 -U lemonldap-ng -W lemonldap-ng< / pre >
< pre class = "code" > Mot de passe pour l' utilisateur lemonldap-ng :
[...]
2017-04-04 20:05:25 +02:00
lemonldap-ng=> create unlogged table sessions ( id char(32) not null primary key, a_session text );
2016-10-15 19:57:04 +02:00
lemonldap-ng=> q< / pre >
2017-04-04 20:05:25 +02:00
< div class = "noteimportant" > Change < code > char(32)< / code > by < code > varchar(64)< / code > if you use the now recommended SHA256 hash algorithm. See < a href = "documentation/latest/sessions.html" class = "wikilink1" title = "documentation:latest:sessions" > Sessions< / a > for more details
2016-10-15 19:57:04 +02:00
< / div >
< / div >
2019-06-28 16:53:45 +02:00
<!-- EDIT3 SECTION "Prepare the database" [468 - 2380] -->
2016-10-15 19:57:04 +02:00
< h3 class = "sectionedit4" id = "manager" > Manager< / h3 >
< div class = "level3" >
< p >
2018-11-26 14:15:43 +01:00
Go in the Manager and set the session module (for example < a href = "https://metacpan.org/pod/Apache::Session::Postgres" class = "urlextern" title = "https://metacpan.org/pod/Apache::Session::Postgres" rel = "nofollow" > Apache::Session::Postgres< / a > for PostgreSQL) in < code > General parameters< / code > » < code > Sessions< / code > » < code > Session storage< / code > » < code > Apache::Session module< / code > and add the following parameters (case sensitive):
2016-10-15 19:57:04 +02:00
< / p >
< div class = "table sectionedit5" > < table class = "inline table table-bordered table-striped" >
< thead >
< tr class = "row0 roweven" >
< th class = "col0 centeralign" colspan = "3" > Required parameters < / th >
< / tr >
< tr class = "row1 rowodd" >
< th class = "col0 centeralign" > Name < / th > < th class = "col1 centeralign" > Comment < / th > < th class = "col2 centeralign" > Example < / th >
< / tr >
< / thead >
< tr class = "row2 roweven" >
2018-11-26 14:15:43 +01:00
< td class = "col0 centeralign" > < strong > DataSource< / strong > < / td > < td class = "col1" > The < a href = "https://metacpan.org/pod/DBI" class = "urlextern" title = "https://metacpan.org/pod/DBI" rel = "nofollow" > DBI< / a > string < / td > < td class = "col2" > dbi:Pg:dbname=sessions;host=10.2.3.1 < / td >
2016-10-15 19:57:04 +02:00
< / tr >
< tr class = "row3 rowodd" >
2019-06-28 16:53:45 +02:00
< td class = "col0 centeralign" > < strong > UserName< / strong > < / td > < td class = "col1" > The database username < / td > < td class = "col2" > lemonldap-ng < / td >
2016-10-15 19:57:04 +02:00
< / tr >
< tr class = "row4 roweven" >
< td class = "col0 centeralign" > < strong > Password< / strong > < / td > < td class = "col1" > The database password < / td > < td class = "col2" > mysuperpassword < / td >
< / tr >
< tr class = "row5 rowodd" >
< td class = "col0 centeralign" > < strong > Commit< / strong > < / td > < td class = "col1" > Required for PostgreSQL < / td > < td class = "col2" > 1 < / td >
< / tr >
< tr class = "row6 roweven" >
2017-04-04 20:05:25 +02:00
< td class = "col0 centeralign" > < strong > TableName< / strong > < / td > < td class = "col1" > < em > (Optional)< / em > Name of the table < / td > < td class = "col2" > sessions < / td >
2016-10-15 19:57:04 +02:00
< / tr >
< / table > < / div >
2019-06-28 16:53:45 +02:00
<!-- EDIT5 TABLE [2703 - 3107] -->
2016-10-15 19:57:04 +02:00
< p >
2019-02-12 17:32:02 +01:00
You must read the man page corresponding to your database (< a href = "https://metacpan.org/pod/Apache::Session::MySQL" class = "urlextern" title = "https://metacpan.org/pod/Apache::Session::MySQL" rel = "nofollow" > Apache::Session::MySQL< / a > , ...) to learn more about parameters. You must also install the database connector (< a href = "https://metacpan.org/pod/DBD::Oracle" class = "urlextern" title = "https://metacpan.org/pod/DBD::Oracle" rel = "nofollow" > https://metacpan.org/pod/DBD::Oracle< / a > , < a href = "https://metacpan.org/pod/DBD::Pg" class = "urlextern" title = "https://metacpan.org/pod/DBD::Pg" rel = "nofollow" > DBD::Pg< / a > ,...)
2016-10-15 19:57:04 +02:00
< / p >
2018-06-07 13:48:21 +02:00
< div class = "noteimportant" > For MySQL, you need to set additional parameters:< ul >
2016-10-15 19:57:04 +02:00
< li class = "level1" > < div class = "li" > LockDataSource< / div >
< / li >
< li class = "level1" > < div class = "li" > LockUserName< / div >
< / li >
< li class = "level1" > < div class = "li" > LockPassword< / div >
< / li >
< / ul >
2018-06-25 23:17:51 +02:00
< / div > < div class = "notetip" > For better performances, you can use specific < a href = "browseablesessionbackend.html" class = "wikilink1" title = "documentation:2.0:browseablesessionbackend" > browseable session backend< / a > .
2016-10-15 19:57:04 +02:00
< p >
2018-06-07 13:48:21 +02:00
Learn more at < a href = "performances.html#apachesession_performances" class = "wikilink1" title = "documentation:2.0:performances" > how to increase Data Base performances< / a > .
2016-10-15 19:57:04 +02:00
< / p >
2018-06-07 13:48:21 +02:00
< / div >
2016-10-15 19:57:04 +02:00
< / div >
2017-08-30 18:47:22 +02:00
< h4 id = "utf8_support" > UTF8 support< / h4 >
< div class = "level4" >
< p >
If you may store some non-< abbr title = "American Standard Code for Information Interchange" > ASCII< / abbr > characters, you must add the parameter corresponding to your database.
< / p >
< div class = "table sectionedit6" > < table class = "inline table table-bordered table-striped" >
< thead >
< tr class = "row0 roweven" >
< th class = "col0 centeralign" > Database < / th > < th class = "col1 centeralign" > Parameter name < / th > < th class = "col2 centeralign" > Value < / th >
< / tr >
< / thead >
< tr class = "row1 rowodd" >
< td class = "col0 centeralign" > MySQL < / td > < td class = "col1 centeralign" > mysql_enable_utf8 < / td > < td class = "col2 centeralign" > 1 < / td >
< / tr >
< tr class = "row2 roweven" >
< td class = "col0 centeralign" > PostgreSQL < / td > < td class = "col1 centeralign" > pg_enable_utf8 < / td > < td class = "col2 centeralign" > 1 < / td >
< / tr >
< tr class = "row3 rowodd" >
< td class = "col0 centeralign" > SQLite < / td > < td class = "col1 centeralign" > sqlite_unicode < / td > < td class = "col2 centeralign" > 1 < / td >
< / tr >
< / table > < / div >
2019-06-28 16:53:45 +02:00
<!-- EDIT6 TABLE [3897 - 4060] -->
2017-08-30 18:47:22 +02:00
< / div >
2019-06-28 16:53:45 +02:00
<!-- EDIT4 SECTION "Manager" [2381 - 4061] -->
2017-08-30 18:47:22 +02:00
< h2 class = "sectionedit7" id = "security" > Security< / h2 >
2016-10-15 19:57:04 +02:00
< div class = "level2" >
< p >
Restrict network access to the database.
< / p >
< p >
You can also use different user/password for your servers by overriding parameters < code > globalStorage< / code > and < code > globalStorageOptions< / code > in lemonldap-ng.ini file.
< / p >
< / div >
2019-06-28 16:53:45 +02:00
<!-- EDIT7 SECTION "Security" [4062 - ] --> < / div >
2016-10-15 19:57:04 +02:00
< / body >
< / html >