From e771ec500a6f23f28cc83e9d0f12854f65b3c24f Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Tue, 17 Jan 2012 08:18:13 +0100 Subject: [PATCH] fix bug #86: correctly decode cookie --- PVE/REST.pm | 9 ++++++++- debian/changelog.Debian | 2 ++ www/manager/Workspace.js | 3 ++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/PVE/REST.pm b/PVE/REST.pm index cf50e203..911ba096 100644 --- a/PVE/REST.pm +++ b/PVE/REST.pm @@ -18,6 +18,7 @@ use HTML::Entities; use PVE::JSONSchema; use PVE::AccessControl; use PVE::RPCEnvironment; +use URI::Escape; use Data::Dumper; # fixme: remove @@ -44,7 +45,13 @@ sub extract_auth_cookie { return undef if !$cookie; - return ($cookie =~ /(?:^|\s)$cookie_name=([^;]*)/)[0]; + my $ticket = ($cookie =~ /(?:^|\s)$cookie_name=([^;]*)/)[0]; + + if ($ticket && $ticket =~ m/^PVE%3A/) { + $ticket = uri_unescape($ticket); + } + + return $ticket; } sub create_auth_cookie { diff --git a/debian/changelog.Debian b/debian/changelog.Debian index 380256f5..1d333774 100644 --- a/debian/changelog.Debian +++ b/debian/changelog.Debian @@ -2,6 +2,8 @@ pve-manager (2.0-20) unstable; urgency=low * fix bug #85: allow root@pam to generate tickets for other users + * fix bug #86: correctly decode cookie + -- Proxmox Support Team Tue, 17 Jan 2012 06:36:23 +0100 pve-manager (2.0-19) unstable; urgency=low diff --git a/www/manager/Workspace.js b/www/manager/Workspace.js index 889b7a12..7145025e 100644 --- a/www/manager/Workspace.js +++ b/www/manager/Workspace.js @@ -26,6 +26,8 @@ Ext.define('PVE.Workspace', { me.loginData = loginData; PVE.CSRFPreventionToken = loginData.CSRFPreventionToken; PVE.UserName = loginData.username; + var expire = Ext.Date.add(new Date(), Ext.Date.HOUR, 2); + Ext.util.Cookies.set('PVEAuthCookie', loginData.ticket, expire); me.onLogin(loginData); }, @@ -88,7 +90,6 @@ Ext.define('PVE.Workspace', { url: '/api2/json/access/ticket', method: 'POST', success: function(response, opts) { - // cookie is automatically updated var obj = Ext.decode(response.responseText); me.updateLoginData(obj.data); }