Parse JSON login forms for F5
Lots of F5 VPNs don't send normal HTML authentication forms at all, but instead generate forms on-the-fly using JavaScript.
Until now, we've "faked it" by just assuming that the initial login form contains plain username/password fields, but in #512 we have a case where there's a subsequent "challenge" form which also lacks an HTML rendering.
We don't want to actually execute JavaScript in OpenConnect, but as far as
we can tell, these JavaScript forms always involve a <script>
tag
containing a call to a function appLoader.configure()
, with a JSON object
literal as its sole argument, and that object contains the details of the
form fields. Like so:
<script type="text/javascript">appLoader.configure({"logon": {
"form": {
"id": "auth_form",
"title": "Please log into our F5 VPN",
"fields": [
{"type": "text", "name": "username", "caption": "Username", "value": "", "disabled": false},
{"type": "password", "name": "password", "caption": "Password", "value": "", "disabled": false}
]
}
});
</script>
Since we have json-parser as a dependency, let's parse that awful mess, and build our authentication form from it. Yay, JSON.