192 lines
8.3 KiB
HTML
192 lines
8.3 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en" dir="ltr">
|
|
<head>
|
|
<meta charset="utf-8" />
|
|
<title>documentation:2.0:restservices</title>
|
|
<meta name="generator" content="DokuWiki"/>
|
|
<meta name="robots" content="index,follow"/>
|
|
<meta name="keywords" content="documentation,2.0,restservices"/>
|
|
<link rel="search" type="application/opensearchdescription+xml" href="lib/exe/opensearch.html" title="LemonLDAP::NG"/>
|
|
<link rel="start" href="restservices.html"/>
|
|
<link rel="contents" href="restservices.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:restservices","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="#portal_rest_services">Portal REST services</a></div>
|
|
<ul class="toc">
|
|
<li class="level2"><div class="li"><a href="#authentication">Authentication</a></div>
|
|
<ul class="toc">
|
|
<li class="level3"><div class="li"><a href="#api">API</a></div></li>
|
|
<li class="level3"><div class="li"><a href="#example">Example</a></div></li>
|
|
</ul>
|
|
</li>
|
|
<li class="level2"><div class="li"><a href="#sessions">Sessions</a></div></li>
|
|
<li class="level2"><div class="li"><a href="#configuration">Configuration</a></div></li>
|
|
</ul></li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
<!-- TOC END -->
|
|
|
|
<h1 class="sectionedit1" id="rest_services">REST services</h1>
|
|
<div class="level1">
|
|
|
|
<p>
|
|
<abbr title="LemonLDAP::NG">LL::NG</abbr> portal is a REST server that gives access to configuration, session and also authentication.
|
|
</p>
|
|
|
|
</div>
|
|
<!-- EDIT1 SECTION "REST services" [1-130] -->
|
|
<h2 class="sectionedit2" id="portal_rest_services">Portal REST services</h2>
|
|
<div class="level2">
|
|
|
|
</div>
|
|
<!-- EDIT2 SECTION "Portal REST services" [131-164] -->
|
|
<h3 class="sectionedit3" id="authentication">Authentication</h3>
|
|
<div class="level3">
|
|
|
|
<p>
|
|
The authentication service is always available with REST, you just need to send credentials on portal <abbr title="Uniform Resource Locator">URL</abbr>. But by default, the portal is protected by <a href="security.html#portal" class="wikilink1" title="documentation:2.0:security">one time tokens to prevent CSRF</a>. You must disable them or set a rule (configuration parameter <code>requireToken</code>) so token will not be required for REST requests, for example:
|
|
</p>
|
|
<pre class="code perl"><span class="re0">$env</span><span class="sy0">-></span><span class="br0">{</span>HTTP_ACCEPT<span class="br0">}</span> <span class="sy0">!~</span> <a href="http://perldoc.perl.org/functions/m.html"><span class="kw3">m</span></a><span class="sy0">:</span>application<span class="sy0">/</span>json<span class="sy0">:</span></pre>
|
|
|
|
</div>
|
|
|
|
<h4 id="api">API</h4>
|
|
<div class="level4">
|
|
|
|
<p>
|
|
Request parameters:
|
|
</p>
|
|
<ul>
|
|
<li class="level1"><div class="li"> Endpoint: <code>/</code></div>
|
|
</li>
|
|
<li class="level1"><div class="li"> Method: <code>POST</code></div>
|
|
</li>
|
|
<li class="level1"><div class="li"> Request headers:</div>
|
|
<ul>
|
|
<li class="level2"><div class="li"> <code>Accept</code>: <code>application/json</code></div>
|
|
</li>
|
|
</ul>
|
|
</li>
|
|
<li class="level1"><div class="li"> POST data:</div>
|
|
<ul>
|
|
<li class="level2"><div class="li"> <code>user</code>: user login</div>
|
|
</li>
|
|
<li class="level2"><div class="li"> <code>password</code>: user password</div>
|
|
</li>
|
|
<li class="level2"><div class="li"> xxx: optional parameters, like <code>lmAuth</code> if your portal uses <code>Choice</code> or <code>spoofId</code> to impersonate.</div>
|
|
</li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
|
|
<p>
|
|
The JSON response fields are:
|
|
</p>
|
|
<ul>
|
|
<li class="level1"><div class="li"> <code>result</code>: authentication result, <code>0</code> if it fails, <code>1</code> if it succeed</div>
|
|
</li>
|
|
<li class="level1"><div class="li"> <code>error</code>: error code, the corresponding error can be found in <code>Lemonldap::NG::Portal::Main::Constants</code></div>
|
|
</li>
|
|
<li class="level1"><div class="li"> <code>id</code>: if authentication succeed, the session id is returned in this field</div>
|
|
</li>
|
|
</ul>
|
|
<div class="notetip">You can also get the cookie by reading the response header <code>Cookie</code> returned by the portal.
|
|
</div><div class="noteimportant">Before version 2.0.4, the response to a success authentication had no <code>id</code> field, and <code>error</code> field was named <code>code</code> <em>(use Cookie header to get id value)</em>.
|
|
</div>
|
|
</div>
|
|
|
|
<h4 id="example">Example</h4>
|
|
<div class="level4">
|
|
<ul>
|
|
<li class="level1"><div class="li"> Request with curl:</div>
|
|
</li>
|
|
</ul>
|
|
<pre class="code">curl -H "Accept: application/json" -d user=rtyler -d password=rtyler http://auth.example.com/ | json_pp</pre>
|
|
<ul>
|
|
<li class="level1"><div class="li"> Response for bad authentication:</div>
|
|
</li>
|
|
</ul>
|
|
<pre class="code javascript"><span class="br0">{</span>
|
|
<span class="st0">"result"</span> <span class="sy0">:</span> <span class="nu0">0</span><span class="sy0">,</span>
|
|
<span class="st0">"error"</span> <span class="sy0">:</span> <span class="nu0">5</span>
|
|
<span class="br0">}</span></pre>
|
|
<ul>
|
|
<li class="level1"><div class="li"> Response for good authentication:</div>
|
|
</li>
|
|
</ul>
|
|
<pre class="code javascript"><span class="br0">{</span>
|
|
<span class="st0">"result"</span> <span class="sy0">:</span> <span class="nu0">1</span><span class="sy0">,</span>
|
|
<span class="st0">"error"</span> <span class="sy0">:</span> <span class="st0">"0"</span><span class="sy0">,</span>
|
|
<span class="st0">"id"</span> <span class="sy0">:</span> <span class="st0">"b048bf87ca401da1d89419813e3acf466d5e4465fe3a1f7adfd8240bd161bde2"</span>
|
|
<span class="br0">}</span></pre>
|
|
|
|
</div>
|
|
<!-- EDIT3 SECTION "Authentication" [165-1962] -->
|
|
<h3 class="sectionedit4" id="sessions">Sessions</h3>
|
|
<div class="level3">
|
|
|
|
<p>
|
|
REST functions for sessions are protected by Web Server, you can change this in <a href="configlocation.html#portal" class="wikilink1" title="documentation:2.0:configlocation">portal configuration</a>.
|
|
</p>
|
|
|
|
<p>
|
|
See <a href="restsessionbackend.html" class="wikilink1" title="documentation:2.0:restsessionbackend">REST session backend documentation</a> for more.
|
|
</p>
|
|
|
|
</div>
|
|
<!-- EDIT4 SECTION "Sessions" [1963-2184] -->
|
|
<h3 class="sectionedit5" id="configuration">Configuration</h3>
|
|
<div class="level3">
|
|
|
|
<p>
|
|
REST functions for configuration are protected by Web Server, you can change this in <a href="configlocation.html#portal" class="wikilink1" title="documentation:2.0:configlocation">portal configuration</a>.
|
|
</p>
|
|
|
|
<p>
|
|
See <a href="restconfbackend.html" class="wikilink1" title="documentation:2.0:restconfbackend">REST configuration backend documentation</a> for more.
|
|
</p>
|
|
|
|
</div>
|
|
<!-- EDIT5 SECTION "Configuration" [2185-] --></div>
|
|
</body>
|
|
</html>
|