fix bug #86: correctly decode cookie

This commit is contained in:
Dietmar Maurer 2012-01-17 08:18:13 +01:00
parent d45576dfb9
commit ce2d54c943
3 changed files with 12 additions and 2 deletions

View File

@ -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 {

View File

@ -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 <support@proxmox.com> Tue, 17 Jan 2012 06:36:23 +0100
pve-manager (2.0-19) unstable; urgency=low

View File

@ -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);
}