Debian Codegraph @

doc/sources/admin/redirections.rst

raw
1 Redirections
2 ============
3
4 Handler Redirections
5 --------------------
6
7
8 .. note::
9
10 When a user access a Handler without a cookie, he is redirected on
11 portal, and the target URL is encoded in redirection URL (to redirect
12 user after authentication process).
13
14 Protocol and port
15 ~~~~~~~~~~~~~~~~~
16
17 To encode the redirection URL, the handler will use some Apache
18 environment variables and also configuration settings:
19
20 - **HTTPS**: use https as protocol
21 - **Port**: port of the application (by default, 80 for http, 443 for
22 https)
23
24 These parameters can be configured in Manager, in ``General Parameters``
25 > ``Advanced parameters`` > ``Handler redirections``.
26
27
28 .. tip::
29
30 These settings can be overridden per virtual host, see
31 :doc:`virtual host management<configvhost>`.
32
33 Forbidden and Server error
34 ~~~~~~~~~~~~~~~~~~~~~~~~~~
35
36 Handler use the default Apache error code for the following cases:
37
38 - User has no access authorization: FORBIDDEN (403)
39 - An error occurs on server side: SERVER_ERROR (500)
40 - The application is in maintenance: HTTP_SERVICE_UNAVAILABLE (503)
41
42 These errors can be catch through Apache ``ErrorDocument`` directive or
43 Nginx ``error_page`` directive, to redirect user on a specific page:
44
45 .. code-block:: apache
46
47 # Apache: Common error page and security parameters
48 ErrorDocument 403 http://auth.example.com/lmerror/403
49 ErrorDocument 500 http://auth.example.com/lmerror/500
50 ErrorDocument 503 http://auth.example.com/lmerror/503
51
52
53 With Nginx, you must add these directives in the `location / {` section:
54
55 .. code-block:: nginx
56
57 # Nginx: Common error page and security parameters
58 error_page 403 http://auth.example.com/lmerror/403;
59 error_page 500 http://auth.example.com/lmerror/500;
60 error_page 503 http://auth.example.com/lmerror/503;
61
62 It is also possible to redirect the user without using
63 ``ErrorDocument``: the Handler will not return 403, 500, 503 code, but
64 code 302 (REDIRECT).
65
66 The user will be redirected on portal URL with error in the ``lmerror`` route.
67
68 These parameters can be configured in Manager, in ``General Parameters``
69 > ``Advanced parameters`` > ``Handler redirections``:
70
71 - **Redirect AJAX requests on unauthorized**: use 302 instead of 401 when AJAX requests are not authenticated (available only with AJAX requests accepting JSON format)
72 - **Redirect on forbidden**: use 302 instead 403
73 - **Redirect on error**: use 302 instead 500 or 503
74
75 Portal Redirections
76 -------------------
77
78
79 .. note::
80
81 If a user is redirected from handler to portal for authentication
82 and once he is authenticated, portal redirects him to the redirection
83 URL.
84
85 - **Redirection message**: The redirection from portal can be done
86 either with code 303 (See Other), or with a JavaScript redirection.
87 Often the redirection takes some time because it is user's first
88 access to the protected app, so a new app session has to be created :
89 JavaScript redirection improves user experience by informing that
90 authentication is performed, and by preventing from clicking again on
91 the button because it is too slow.
92 - **Keep redirections for Ajax**: By default, when an Ajax request is
93 done on the portal for an unauthenticated user (after a redirection
94 done by the handler), a 401 code will be sentwith a
95 ``WWW-Authenticate`` header containing "SSO <portal-URL>". Set this
96 option to 1 to keep the old behavior (return of HTML code).
97 - **Skip re-auth confirmation**: by default, when re-authentication is
98 needed, a confirmation screen is displayed to let user accept the
99 re-authentication. If you enable this option, user will be directly
100 redirected to login page.
101 - **Skip upgrade confirmation**: by default, when upgrade is needed,
102 a confirmation screen is displayed to let user accept the authentication
103 level upgrade. If you enable this option, user will be directly
104 redirected to 2FA page.
105 - **External menu URL**: If set, authenticated users will be redirected
106 to this URL instead of seeing the portal menu. This URL supports
107 session variables interpolation (e.g. ``$uid``, ``$mail``). Note: if
108 the user was redirected to the portal with a target URL (via the
109 ``url`` query parameter), that target URL takes priority over this
110 setting.