lemonldap-ng/doc/pages/documentation/current/customhandlers.html
2019-02-12 17:32:02 +01:00

176 lines
8.1 KiB
HTML

<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8" />
<title>documentation:2.0:customhandlers</title>
<meta name="generator" content="DokuWiki"/>
<meta name="robots" content="index,follow"/>
<meta name="keywords" content="documentation,2.0,customhandlers"/>
<link rel="search" type="application/opensearchdescription+xml" href="lib/exe/opensearch.html" title="LemonLDAP::NG"/>
<link rel="start" href="customhandlers.html"/>
<link rel="contents" href="customhandlers.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:2.0';var JSINFO = {"id":"documentation:2.0:customhandlers","namespace":"documentation:2.0"};
/*!]]>*/</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="/static/bwr/jquery-ui/jquery-ui.min.js"></script>
//else -->
<script type="text/javascript" src="/static/bwr/jquery-ui/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="#add_a_new_handler_type">Add a new handler type</a></div>
<ul class="toc">
<li class="level2"><div class="li"><a href="#enable_it">Enable it</a></div></li>
</ul>
</li>
<li class="level1"><div class="li"><a href="#add_a_new_platform">Add a new platform</a></div></li>
<li class="level1"><div class="li"><a href="#old_fashion_nginx_handlers">Old fashion Nginx handlers</a></div></li>
</ul>
</div>
</div>
<!-- TOC END -->
<h1 class="sectionedit1" id="custom_handlers">Custom handlers</h1>
<div class="level1">
<p>
LLNG provides Perl libraries that can be easily used by inheritance. So you can write your own handlers but you need first to understand <a href="handlerarch.html" class="wikilink1" title="documentation:2.0:handlerarch">Handler architecture</a>
</p>
</div>
<!-- EDIT1 SECTION "Custom handlers" [1-206] -->
<h2 class="sectionedit2" id="add_a_new_handler_type">Add a new handler type</h2>
<div class="level2">
<ol>
<li class="level1"><div class="li"> Write your new Module (in Lemonldap/NG/Handler/Lib for example) that overload some Lemonldap::NG::Handler::Main methods</div>
</li>
<li class="level1"><div class="li"> Write a wrapper in each platform directory <em>(see Lemonldap::NG::Handler::Apache2::AuthBasic or Lemonldap::NG::Handler::Server::AuthBasic for examples)</em></div>
</li>
</ol>
<p>
Wrapper usually look at this:
</p>
<pre class="code file perl"><a href="http://perldoc.perl.org/functions/package.html"><span class="kw3">package</span></a> Lemonldap<span class="sy0">::</span><span class="me2">NG</span><span class="sy0">::</span><span class="me2">Handler</span><span class="sy0">::</span><span class="me2">ApacheMP2</span><span class="sy0">::</span><span class="me2">MyType</span><span class="sy0">;</span>
&nbsp;
<span class="kw2">use</span> base <span class="st_h">'Lemonldap::NG::Handler::ApacheMP2::Main'</span><span class="sy0">,</span> <span class="st_h">'Lemonldap::NG::Handler::Lib::MyType'</span><span class="sy0">;</span>
&nbsp;
<span class="nu0">1</span><span class="sy0">;</span></pre>
</div>
<!-- EDIT2 SECTION "Add a new handler type" [207-723] -->
<h3 class="sectionedit3" id="enable_it">Enable it</h3>
<div class="level3">
<p>
Your wrappers must be named “Lemonldap::NG::Handler::&lt;platform&gt;::&lt;type&gt;” where &lt;platform&gt; is the target (ApacheMP2 or Server) and &lt;type&gt; is the name you&#039;ve chosen.
</p>
<p>
You can enable it either:
</p>
<ul>
<li class="level1"><div class="li"> by setting a <code>PerlSetVar VHOSTTYPE &lt;type&gt;</code> in the Apache configuration file</div>
</li>
<li class="level1"><div class="li"> by setting a <code>fastcgi_param VHOSTTYPE &lt;type&gt;</code> in the Nginx configuration file</div>
</li>
<li class="level1"><div class="li"> by adding it to the menu: add its name in <code>vhostType</code> “select” declaration (file <code>lemonldap-ng-manager/lib/Lemonldap/NG/Build/Attributes</code>) and rebuild LLNG</div>
</li>
</ul>
<p>
Note that configuration parameter can be set only in lemonldap-ng.ini configuration file <em>(section Handler)</em>.
</p>
</div>
<!-- EDIT3 SECTION "Enable it" [724-1379] -->
<h2 class="sectionedit4" id="add_a_new_platform">Add a new platform</h2>
<div class="level2">
<p>
LLNG provides 3 platforms:
</p>
<ul>
<li class="level1"><div class="li"> ApacheMP2</div>
</li>
<li class="level1"><div class="li"> FastCGI server <em>(Nginx is build from there)</em></div>
</li>
<li class="level1"><div class="li"> Auto-protected PSGI</div>
</li>
</ul>
<p>
If you want to add another, you must write:
</p>
<ul>
<li class="level1"><div class="li"> the platform launcher file that launch the required type <em>(see <code>lemonldap-ng-handler/lib/Lemonldap/NG/Handler/ApacheMP2</code> file for example)</em></div>
</li>
<li class="level1"><div class="li"> write the main platform file (<code>Lemonldap::NG::Handler::MyPlatform::Main</code>) that provides required method <em>(see <code>lemonldap-ng-handler/lib/Lemonldap/NG/Handler/*/Main</code> for examples)</em> and inherits from <code>Lemonldap::NG::Handler::Main</code></div>
</li>
<li class="level1"><div class="li"> write the “type” wrapper files (AuthBasic,...).</div>
</li>
</ul>
<p>
Wrapper usually look at this:
</p>
<pre class="code file perl"><a href="http://perldoc.perl.org/functions/package.html"><span class="kw3">package</span></a> Lemonldap<span class="sy0">::</span><span class="me2">NG</span><span class="sy0">::</span><span class="me2">Handler</span><span class="sy0">::</span><span class="me2">MyPlatform</span><span class="sy0">::</span><span class="me2">AuthBasic</span><span class="sy0">;</span>
&nbsp;
<span class="kw2">use</span> base <span class="st_h">'Lemonldap::NG::Handler::MyPlatform::Main'</span><span class="sy0">,</span> <span class="st_h">'Lemonldap::NG::Handler::Lib::AuthBasic'</span><span class="sy0">;</span>
&nbsp;
<span class="nu0">1</span><span class="sy0">;</span></pre>
</div>
<!-- EDIT4 SECTION "Add a new platform" [1380-2220] -->
<h2 class="sectionedit5" id="old_fashion_nginx_handlers">Old fashion Nginx handlers</h2>
<div class="level2">
<div class="noteimportant">There is no need to use this feature now. It is kept for compatibility.
</div>
<p>
Three actions are needed:
</p>
<ul>
<li class="level1"><div class="li"> declare your own module in the manager “General Parameters &gt;&gt; Advanced Parameters &gt;&gt; Custom handlers (Nginx)”. Key is the name that will be used below and value is the name of the custom package,</div>
</li>
<li class="level1"><div class="li"> in your Nginx configuration file, add <code>LLTYPE=&lt;name&gt;;</code> in the <code>location = /lmauth {...}</code> paragraph</div>
</li>
<li class="level1"><div class="li"> restart FastCGI server(s) <em>(reload is not enough here)</em></div>
</li>
</ul>
</div>
<!-- EDIT5 SECTION "Old fashion Nginx handlers" [2221-] --></div>
</body>
</html>