diff options
author | Christian Pointner <equinox@helsinki.at> | 2015-07-28 12:52:04 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@helsinki.at> | 2015-07-28 12:52:04 (GMT) |
commit | 2d2af4466b914d9e2b7ddf3cd2b50d02504fdc23 (patch) | |
tree | 4b27cabe2ebaebcb1d76f5fe63b7322d6a949fba | |
parent | d2fb142fc08989cd0397ecfb3941e35851a28ec9 (diff) |
moved authtoken.json to rh-bin/ and change it to use Json Library for correct escaping
-rw-r--r-- | README | 5 | ||||
-rwxr-xr-x | rh-bin/authtoken.json (renamed from authtoken.json) | 15 | ||||
-rw-r--r-- | www/js/auth.js | 2 |
3 files changed, 11 insertions, 11 deletions
@@ -30,7 +30,7 @@ LICENSE Installation ============ -# sudo aptitude install apache2 libapache2-mod-perl2 libconfig-inifiles-perl libdbd-mysql-perl librhrd-perl libjs-jquery rivendell-server +# sudo aptitude install apache2 libapache2-mod-perl2 libconfig-inifiles-perl libdbd-mysql-perl libjson-pp-perl librhrd-perl libjs-jquery rivendell-server # sudo a2enmod ssl authnz_ldap perl proxy_wstunnel # sudo /etc/init.d/apache2 restart @@ -69,8 +69,7 @@ add the following to the virtualhost config: Require all granted </Location> - Alias /authtoken.json /var/www/rhwebimport/authtoken.json - <Location /authtoken.json> + <Location /rh-bin/authtoken.json> SetHandler perl-script PerlResponseHandler ModPerl::Registry PerlOptions +ParseHeaders diff --git a/authtoken.json b/rh-bin/authtoken.json index 12e390f..f746518 100755 --- a/authtoken.json +++ b/rh-bin/authtoken.json @@ -22,6 +22,7 @@ use strict; use RHRD::rddb; +use JSON; my $status = 'ERROR'; my $errorstring = 'unknown'; @@ -40,11 +41,11 @@ if(defined $ENV{REMOTE_USER}) { $errorstring = 'no username defined - are you logged in?'; } -print "Content-type: application/json; charset=UTF-8\n\n"; +my %answer; +$answer{'status'} = $status; +$answer{'errorstring'} = $errorstring; +$answer{'username'} = $username; +$answer{'token'} = $token; -print "{\n"; -print ' "status": "' . $status . '"'. ",\n"; -print ' "errorstring": "' . $errorstring . '"'. ",\n"; -print ' "username": "' . $username . '"' . ",\n"; -print ' "token": "' . $token . '"' . "\n"; -print "}\n"; +print "Content-type: application/json; charset=UTF-8\n\n"; +print encode_json \%answer; diff --git a/www/js/auth.js b/www/js/auth.js index 44adc6f..8da85c8 100644 --- a/www/js/auth.js +++ b/www/js/auth.js @@ -51,7 +51,7 @@ function auth_loginError(req, status, error) { } function auth_login() { - $.ajax("/authtoken.json", + $.ajax("/rh-bin/authtoken.json", { cache: false, username: $("#username").val(), password: $("#password").val(), |