Debian Codegraph @

doc/sources/admin/servertoserver.rst

raw
1 Handling server webservice calls
2 ================================
3
4 In modern applications, web application may need to request some other
5 web applications on behalf of the authenticated users. There are three
6 ways to do this:
7
8 - the Ugly: provide to all applications SSO cookie. Not secured
9 because SSO cookie can be caught and used everywhere, every time by
10 everyone!!! **NOT RECOMMENDED**.
11 - the Bad (:doc:`Secure Token Handler<securetoken>`): **Deprecated**.
12 Should be used for specific cases
13 - the Good (Service Token Handler): See below! (Thanks Sergio...)
14
15 The "Bad" method consists to give the token (cookie value) to WebApp1
16 which uses it as cookie header in its request. Since 2.0 version, LL::NG
17 gives a better way (the Good!) to do this by using limited scope
18 tokens.
19
20 Tokens are time limited (30 seconds by default) and URL restricted.
21
22 |Kinematic|
23
24 Webapp1 handler configuration
25 -----------------------------
26
27 Select **Main** handler type to protect WebApp1 and append a header containing:
28
29 .. code-block:: perl
30
31 token($_session_id, 'test.example.com', '/^webapp[23]\.example\.c/', 'serviceHeader1=webapp1.example.com', "testHeader=$uid")
32
33 WebApp1 can retrieve this header and use it in its requests to query other server(s) by setting
34 the ``X-LLNG-TOKEN`` header. The ServiceToken is built by using the ``token`` extended function.
35 This function takes a list of parameters:
36
37 - session ID that must be the first one: ``$_session_id``
38 - virtual hosts authorized to be requested by WebApp1. It can be some strings defining VHosts explicitly or regular expressions that must start and end with a slash ``/`` character.
39 - ServiceHeaders that will be sent to requested apps. A ServiceHeader is defined like this: ``headerName1=headerValue1``
40
41 A ServiceToken is only valid for the authorized virtual hosts and during a restricted time period (30 seconds by default).
42 It can also be used for sending ServiceHeaders (headerName1=headerValue1) to requested apps. A ServiceHeader can be useful
43 to send the source host by example. ServiceHeaders are sent to ALL requested applications.
44 You can define ServiceToken TTL by setting relative option for each requested virtualHost in Manager.
45
46 You can also set ServiceToken default timeout (30 seconds) by editing ``lemonldap-ng.ini`` in section [handler]:
47
48 .. code-block:: ini
49
50 [handler]
51 handlerServiceTokenTTL = 30
52
53
54 .. note::
55
56 ServiceToken timeout can be set for each virtual hosts.
57
58 Webapp2 handler configuration
59 -----------------------------
60
61 Change handler type to **ServiceToken**. And that's all!
62
63 .. note::
64
65 ServiceToken handler inherits from Main handler. So it is able to manage both user and server connections.
66
67 .. |Kinematic| image:: documentation/server_to_server.png
68
69
70 If you want to protect only a virtualHost part (location), keep handler type on "Main"
71 and set type in your configuration file:
72
73 - Apache: just use ``PerlSetVar VHOSTTYPE ServiceToken`` directive
74 - Nginx: create another FastCGI parameter with ``fastcgi_param VHOSTTYPE ServiceToken;``