File: sqlsessionbackend.html

package info (click to toggle)
lemonldap-ng 1.9.7-3%2Bdeb9u2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 39,024 kB
  • sloc: perl: 37,552; makefile: 922; sh: 472; sql: 5
file content (224 lines) | stat: -rw-r--r-- 10,717 bytes parent folder | download
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
  <meta charset="utf-8" />
  <title>documentation:1.9:sqlsessionbackend</title>
<meta name="generator" content="DokuWiki"/>
<meta name="robots" content="index,follow"/>
<meta name="keywords" content="documentation,1.9,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"/>
<!-- //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 -->
<script type="text/javascript">/*<![CDATA[*/var NS='documentation:1.9';var JSINFO = {"id":"documentation:1.9:sqlsessionbackend","namespace":"documentation:1.9"};
/*!]]>*/</script>
<script type="text/javascript" charset="utf-8" src="lib/exe/js.php.t.bootstrap3.js"></script>
<!-- //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
  <script type="text/javascript" src="/lib/scripts/jquery-ui.min.js"></script>
//else -->
  <script type="text/javascript" src="/lib/scripts/jquery-ui.js"></script>
<!-- //endif -->
</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>
<li class="level2"><div class="li"><a href="#manager">Manager</a></div></li>
</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>
<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 class="noteimportant">If your database doesn&#039;t accept UTF-8 characters in &#039;text&#039; field, use &#039;blob&#039; instead of &#039;text&#039;.

</div>
</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 text
    <span class="br0">&#41;</span>;</pre>
<div class="noteimportant">Change char(32) by char(64) if you use the now recommanded SHA256 hash algorithm. See <a href="documentation/latest/sessions.html" class="wikilink1" title="documentation:latest:sessions">Sessions</a> for more details
</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.
</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 : &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>
<div class="noteimportant">Change char(32) by char(64) if you use the now recommanded SHA256 hash algorithm. See <a href="documentation/latest/sessions.html" class="wikilink1" title="documentation:latest:sessions">Sessions</a> for more details
</div>
</div>
<!-- EDIT3 SECTION "Prepare the database" [488-2206] -->
<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 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">
		<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>
	<tr class="row6 roweven">
		<td class="col0 centeralign">  <strong>TableName</strong>  </td><td class="col1"> Name of the table </td><td class="col2"> sessions </td>
	</tr>
</table></div>
<!-- EDIT5 TABLE [2535-2929] -->
<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>
<div class="notetip">For MySQL, you need to set additional parameters:<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>

</div>
<p>
If you choose to use MySQL, read <a href="performances.html#apachesession_performances" class="wikilink1" title="documentation:1.9:performances">how to increase MySQL performances</a>.
</p>

</div>
<!-- EDIT4 SECTION "Manager" [2207-3508] -->
<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>
<!-- EDIT6 SECTION "Security" [3509-] --></div>
</body>
</html>