| 1 |
Form replay |
| 2 |
=========== |
| 3 |
|
| 4 |
Presentation |
| 5 |
------------ |
| 6 |
|
| 7 |
Form replay allows you to open a session on a protected application by |
| 8 |
filling a HTML POST login form and autosubmitting it, without asking |
| 9 |
anything to the user. |
| 10 |
|
| 11 |
|
| 12 |
.. danger:: |
| 13 |
|
| 14 |
This kind of SSO mechanism is not clean, and can lead to |
| 15 |
problems, like local password blocking, local session not well closed, |
| 16 |
etc. |
| 17 |
|
| 18 |
Please always try to find another solution to protect your application |
| 19 |
with LL::NG. At least, check if it is not a |
| 20 |
:doc:`known application<applications>`, or |
| 21 |
:doc:`try to adapt its source code<selfmadeapplication>`. |
| 22 |
|
| 23 |
If you configure form replay with LL::NG, the Handler will detect forms |
| 24 |
to fill, add a javascript in the html page to fill form fields with |
| 25 |
dummy data and submit it, then intercept the POST request and add POST |
| 26 |
data in the request body. |
| 27 |
|
| 28 |
POST data can be static values or computed from user's session. |
| 29 |
|
| 30 |
|
| 31 |
.. tip:: |
| 32 |
|
| 33 |
To post user's password, you must enable |
| 34 |
:doc:`password storing<passwordstore>`. In this case you will be able to |
| 35 |
use ``$_password`` to fill any password POST field. |
| 36 |
|
| 37 |
Configuration |
| 38 |
------------- |
| 39 |
|
| 40 |
You should grab some information: |
| 41 |
|
| 42 |
- URI of the html page which contains the form |
| 43 |
- URI the html form is sent to |
| 44 |
- Does the html page load jQuery ? If not, grab a jQuery URL reachable |
| 45 |
by user (any version over jQuery 1.0 is suitable) |
| 46 |
- are there several html forms in the page ? If so, get a jQuery |
| 47 |
selector for the form you want to post |
| 48 |
- is user required to click on a button, for example in order to |
| 49 |
perform some script ? If so, get a jQuery selector for that button |
| 50 |
- names and values of the fields you want to control |
| 51 |
|
| 52 |
If you don't know jQuery selector, just be aware that they are similar |
| 53 |
to css selectors: for example, button#foo points to the html button |
| 54 |
whose id is "foo", and .bar points to all html elements of css class |
| 55 |
"bar". |
| 56 |
|
| 57 |
For example: |
| 58 |
|
| 59 |
- Form page URI: /login.php |
| 60 |
- Target URI: /process.php (if you let this parameter empty, target URI |
| 61 |
is supposed to be the same as form page URI) |
| 62 |
- jQuery URL: |
| 63 |
http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js (if |
| 64 |
you let this parameter empty, jQuery is supposed to be already |
| 65 |
loaded; you can also set ``default`` to point to jQuery URL of LL::NG |
| 66 |
portal) |
| 67 |
- jQuery form selector: #loginForm (if you let this parameter empty, |
| 68 |
browser will fill and submit any html form) |
| 69 |
- jQuery button selector: button.validate (if you let this parameter |
| 70 |
empty, the form will be submitted but no button will be clicked; if |
| 71 |
you set it to "none", no button will be clicked and the form will be |
| 72 |
filled but not submitted) |
| 73 |
- Fields: |
| 74 |
|
| 75 |
- postuid: $uid |
| 76 |
- postmail: $mail |
| 77 |
- poststatic: 'static' |
| 78 |
|
| 79 |
Go in Manager, ``Virtual Hosts`` » ``virtualhost`` » ``Form replay`` and click |
| 80 |
on ``New form replay``. |
| 81 |
|
| 82 |
|image0| |
| 83 |
|
| 84 |
Fill values here: |
| 85 |
|
| 86 |
- **Form URL**: /login.php |
| 87 |
- **Target URL**: /process.php |
| 88 |
- **jQuery URL**: |
| 89 |
http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js |
| 90 |
- **jQuery form selector**: #loginForm |
| 91 |
- **jQuery button selector**: button.validate |
| 92 |
|
| 93 |
Then click on ``New variable`` and add all data with their values, for |
| 94 |
example: |
| 95 |
|
| 96 |
|image1| |
| 97 |
|
| 98 |
|
| 99 |
.. tip:: |
| 100 |
|
| 101 |
You can define more than one form replay URL per virtual |
| 102 |
host. |
| 103 |
|
| 104 |
.. |image0| image:: /documentation/manager-form-replay.png |
| 105 |
:class: align-center |
| 106 |
.. |image1| image:: /documentation/manager-form-replay-vars.png |
| 107 |
:class: align-center |
| 108 |
|