File: header_remote_user_conversion.html

package info (click to toggle)
lemonldap-ng 1.3.3-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 13,084 kB
  • ctags: 2,440
  • sloc: perl: 25,708; makefile: 622; sh: 176; php: 6; sql: 5
file content (86 lines) | stat: -rw-r--r-- 4,183 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

<!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><a name="convert_http_header_into_environment_variable" id="convert_http_header_into_environment_variable">Convert HTTP header into environment variable</a></h1>
<div class="level1">

<p>

Using <acronym title="LemonLDAP::NG">LL::NG</acronym> in reverse proxy mode, you will not have the <code>REMOTE_USER</code> environment variable set. Indeed, this variable is set by the Handler on the physical server hosting the Handler, and not on other servers where the Handler is not installed.
</p>

<p>
Apache <a href="http://httpd.apache.org/docs/current/mod/mod_setenvif.html" class="urlextern" title="http://httpd.apache.org/docs/current/mod/mod_setenvif.html"  rel="nofollow">SetEnvIf module</a> will let you transform the Auth-User <acronym title="Hyper Text Transfer Protocol">HTTP</acronym> header in <code>REMOTE_USER</code> environment variable:
</p>
<pre class="code file apache"><span class="kw1">SetEnvIfNoCase</span> Auth-<span class="kw1">User</span> <span class="st0">&quot;(.*)&quot;</span> REMOTE_USER=$<span class="nu0">1</span></pre>

<p>
This can be used to protect applications relying on <code>REMOTE_USER</code> environment variable in reverse proxy mode. In this case you will have two Apache configuration files:

</p>
<ul>
<li class="level1"><div class="li"> Apache configuration file on <acronym title="LemonLDAP::NG">LL::NG</acronym> reverse proxy (hosting <acronym title="LemonLDAP::NG">LL::NG</acronym> Handler):</div>
</li>
</ul>
<pre class="code file apache">&lt;<span class="kw3">VirtualHost</span> *:80&gt;
        <span class="kw1">ServerName</span> application.example.com
&nbsp;
        PerlHeaderParserHandler My::Package
&nbsp;
        <span class="kw1">ProxyPreserveHost</span> <span class="kw2">on</span>
        <span class="kw1">ProxyPass</span> / http://APPLICATION_IP/
        <span class="kw1">ProxyPassReverse</span> / http://APPLICATION_IP/
&nbsp;
&lt;/<span class="kw3">VirtualHost</span>&gt;</pre>
<ul>
<li class="level1"><div class="li"> Apache configuration file on application server (hosting the application):</div>
</li>
</ul>
<pre class="code file apache">&lt;<span class="kw3">VirtualHost</span> *:80&gt;
        <span class="kw1">ServerName</span> application.example.com
&nbsp;
        <span class="kw1">SetEnvIfNoCase</span> Auth-<span class="kw1">User</span> <span class="st0">&quot;(.*)&quot;</span> REMOTE_USER=$1
&nbsp;
        <span class="kw1">DocumentRoot</span> /var/www/application
&nbsp;
&lt;/<span class="kw3">VirtualHost</span>&gt;</pre>

<p>
<p><div class="notetip">
Sometimes, <acronym title="Hypertext Preprocessor">PHP</acronym> applications also check the <acronym title="Hypertext Preprocessor">PHP</acronym>_AUTH_USER and <acronym title="Hypertext Preprocessor">PHP</acronym>_AUHT_PW environment variables. You can set them the same way:

</p>
<pre class="code file apache"><span class="kw1">SetEnvIfNoCase</span> Auth-<span class="kw1">User</span> <span class="st0">&quot;(.*)&quot;</span> PHP_AUTH_USER=$1
<span class="kw1">SetEnvIfNoCase</span> Auth-Password <span class="st0">&quot;(.*)&quot;</span> PHP_AUTH_PW=$<span class="nu0">1</span></pre>

<p>

Of course, you need to <a href="../../documentation/1.3/passwordstore.html" class="wikilink1" title="documentation:1.3:passwordstore">store password in session</a> to fill <acronym title="Hypertext Preprocessor">PHP</acronym>_AUTH_PW.

</div></p>

</p>

</div>
</div><!-- closes <div class="dokuwiki export">-->