1 /* mandayejs - saml reverse proxy
2 * Copyright (C) 2015 Entr'ouvert
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Affero General Public License as published
6 * by the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Affero General Public License for more details.
14 * You should have received a copy of the GNU Affero General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 var page = require('webpage').create();
19 var system = require('system');
21 var input = JSON.parse(system.stdin.read(2000)); // no .readAll()...
23 page.open(input.address, function() {
24 page.onLoadFinished = function() {
25 console.log(JSON.stringify({'result': 'ok', 'cookies': page.cookies}));
28 page.evaluate(function(input) {
29 if ($(input.username_locator).length == 0) {
30 console.log(JSON.stringify({'result': 'ok', 'cookies': page.cookies}));
33 $(input.username_locator).val(input.username_value);
34 $(input.password_locator).val(input.password_value);
35 $(input.username_locator).parents('form').find('input[type=submit]').click();