lemonldap-ng/doc/pages/documentation/1.9/sqlsessionbackend.html
2015-12-18 09:46:34 +00:00

187 lines
7.8 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
lang="en" dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<!-- metadata -->
<meta name="generator" content="Offline" />
<meta name="version" content="Offline 0.1" />
<!-- style sheet links -->
<link rel="stylesheet" media="all" type="text/css" href="../../../css/all.css" />
<link rel="stylesheet" media="screen" type="text/css" href="../../../css/screen.css" />
<link rel="stylesheet" media="print" type="text/css" href="../../../css/print.css" />
</head>
<body>
<div class="dokuwiki export">
<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>
<li class="level1"><div class="li"> <a href="http://search.cpan.org/perldoc?Apache::Session::MySQL" class="urlextern" title="http://search.cpan.org/perldoc?Apache::Session::MySQL" rel="nofollow">MySQL</a></div>
</li>
<li class="level1"><div class="li"> <a href="http://search.cpan.org/perldoc?Apache::Session::Postgres" class="urlextern" title="http://search.cpan.org/perldoc?Apache::Session::Postgres" rel="nofollow">PostgreSQL</a></div>
</li>
<li class="level1"><div class="li"> <a href="http://search.cpan.org/perldoc?Apache::Session::Oracle" class="urlextern" title="http://search.cpan.org/perldoc?Apache::Session::Oracle" rel="nofollow">Oracle</a></div>
</li>
<li class="level1"><div class="li"> <a href="http://search.cpan.org/perldoc?Apache::Session::Informix" class="urlextern" title="http://search.cpan.org/perldoc?Apache::Session::Informix" rel="nofollow">Informix</a></div>
</li>
<li class="level1"><div class="li"> <a href="http://search.cpan.org/perldoc?Apache::Session::Sybase" class="urlextern" title="http://search.cpan.org/perldoc?Apache::Session::Sybase" rel="nofollow">Sybase</a></div>
</li>
<li class="level1"><div class="li"> ….</div>
</li>
</ul>
</div>
<!-- EDIT1 SECTION "SQL session backend" [1-468] -->
<h2 class="sectionedit2" id="setup">Setup</h2>
<div class="level2">
</div>
<!-- EDIT2 SECTION "Setup" [469-487] -->
<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>
<h4 id="mysql">MySQL</h4>
<div class="level4">
<p>
Create a database if necessary:
</p>
<pre class="code">mysqladmin create lemonldapng</pre>
<p>
Create sessions table:
</p>
<pre class="code file sql"><span class="kw1">CREATE</span> <span class="kw1">TABLE</span> sessions <span class="br0">&#40;</span>
id <span class="kw1">CHAR</span><span class="br0">&#40;</span><span class="nu0">32</span><span class="br0">&#41;</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 <span class="kw1">BLOB</span>
<span class="br0">&#41;</span>;</pre>
<p>
<p><div class="noteimportant">Change char(32) by char(64) if you use the now recommanded SHA256 hash algorithm. See <a href="../../documentation/current/sessions.html" class="wikilink1" title="documentation:latest:sessions">Sessions</a> for more details
</div></p>
</p>
</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 : &lt;PASSWORD&gt;
Entrez-le de nouveau : &lt;PASSWORD&gt;
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&#039;utilisateur lemonldap-ng :
[...]
lemonldap-ng=&gt; create table sessions ( id char(32) not null primary key, a_session text );
lemonldap-ng=&gt; q</pre>
<p>
<p><div class="noteimportant">Change char(32) by char(64) if you use the now recommanded SHA256 hash algorithm. See <a href="../../documentation/current/sessions.html" class="wikilink1" title="documentation:latest:sessions">Sessions</a> for more details
</div></p>
</p>
</div>
<!-- EDIT3 SECTION "Prepare the database" [488-1947] -->
<h3 class="sectionedit4" id="manager">Manager</h3>
<div class="level3">
<p>
Go in the Manager and set the session module (for example <a href="http://search.cpan.org/perldoc?Apache::Session::Postgres" class="urlextern" title="http://search.cpan.org/perldoc?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):
</p>
<div class="table sectionedit5"><table class="inline">
<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">
<td class="col0 centeralign"> <strong>DataSource</strong> </td><td class="col1"> The <a href="http://search.cpan.org/perldoc?DBI" class="urlextern" title="http://search.cpan.org/perldoc?DBI" rel="nofollow">DBI</a> string </td><td class="col2"> dbi:Pg:dbname=sessions;host=10.2.3.1 </td>
</tr>
<tr class="row3 rowodd">
<td class="col0 centeralign"> <strong>UserName</strong> </td><td class="col1"> The database username </td><td class="col2"> lemonldapng </td>
</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>
</table></div>
<!-- EDIT5 TABLE [2276-2619] -->
<p>
You must read the man page corresponding to your database (<a href="http://search.cpan.org/perldoc?Apache::Session::MySQL" class="urlextern" title="http://search.cpan.org/perldoc?Apache::Session::MySQL" rel="nofollow">Apache::Session::MySQL</a>, …) to learn more about parameters. You must also install the database connector (<a href="http://search.cpan.org/perldoc?DBD::Oracle" class="urlextern" title="http://search.cpan.org/perldoc?DBD::Oracle" rel="nofollow">DBD::Oracle</a>, <a href="http://search.cpan.org/perldoc?DBD::Pg" class="urlextern" title="http://search.cpan.org/perldoc?DBD::Pg" rel="nofollow">DBD::Pg</a>,…)
</p>
<p>
<p><div class="notetip">
For MySQL, you need to set additional parameters:
</p>
<ul>
<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>
<p>
</div></p>
</p>
<p>
If you choose to use MySQL, read <a href="../../documentation/1.9/performances.html#apachesession_performances" class="wikilink1" title="documentation:1.9:performances">how to increase MySQL performances</a>.
</p>
</div>
<!-- EDIT4 SECTION "Manager" [1948-3198] -->
<h2 class="sectionedit6" id="security">Security</h2>
<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>
</div><!-- closes <div class="dokuwiki export">-->