Manage cookie expiration (#1131)

This commit is contained in:
Xavier Guimard 2017-03-15 10:01:29 +00:00
parent f6e5356178
commit 126fdb091c
5 changed files with 23 additions and 14 deletions

View File

@ -829,7 +829,7 @@ sub extractFormInfo {
value => 0, value => 0,
domain => $self->conf->{domain}, domain => $self->conf->{domain},
secure => 0, secure => 0,
expires => '-1d', expires => 'Wed, 21 Oct 2015 00:00:00 GMT',
) )
); );
@ -878,13 +878,14 @@ sub extractFormInfo {
# User can choose temporary (0) or persistent cookie (1) # User can choose temporary (0) or persistent cookie (1)
my $cookie_type = $req->param("cookie_type") || "0"; my $cookie_type = $req->param("cookie_type") || "0";
# Cookie available 1 year
$req->addCookie( $req->addCookie(
$self->p->cookie( $self->p->cookie(
name => $self->conf->{samlIdPResolveCookie}, name => $self->conf->{samlIdPResolveCookie},
value => $idp, value => $idp,
domain => $self->conf->{domain}, domain => $self->conf->{domain},
secure => $self->conf->{securedCookie}, secure => $self->conf->{securedCookie},
expires => $cookie_type ? "+365d" : "", ( $cookie_type ? ( max_age => 31557600 ) : () ),
) )
); );
} }

View File

@ -114,12 +114,12 @@ sub extractFormInfo {
my $response = Net::OAuth->response('request token') my $response = Net::OAuth->response('request token')
->from_post_body( $res->content ); ->from_post_body( $res->content );
# 1.2 Store token key and secret in cookies # 1.2 Store token key and secret in cookies (available 180s)
$req->addCookie( $req->addCookie(
$self->cookie( $self->cookie(
name => '_twitSec', name => '_twitSec',
value => $response->token_secret, value => $response->token_secret,
expires => '+3m' max_age => 180,
) )
); );
@ -198,7 +198,12 @@ sub extractFormInfo {
# Clean temporaries cookies # Clean temporaries cookies
$req->addCookie( $req->addCookie(
$self->cookie( -name => '_twitSec', -value => 0, -expires => '-3m' ) ); $self->cookie(
name => '_twitSec',
value => 0,
expires => 'Wed, 21 Oct 2015 00:00:00 GMT'
)
);
PE_OK; PE_OK;
} }

View File

@ -253,7 +253,7 @@ sub extractFormInfo {
value => 0, value => 0,
domain => $self->conf->{domain}, domain => $self->conf->{domain},
secure => 0, secure => 0,
expires => '-1d', expires => 'Wed, 21 Oct 2015 00:00:00 GMT'
) )
); );
return PE_SESSIONEXPIRED; return PE_SESSIONEXPIRED;

View File

@ -483,7 +483,7 @@ sub _deleteSession {
value => 0, value => 0,
domain => $self->conf->{domain}, domain => $self->conf->{domain},
secure => 0, secure => 0,
expires => '-1d', expires => 'Wed, 21 Oct 2015 00:00:00 GMT'
) )
) unless ($preserveCookie); ) unless ($preserveCookie);
} }
@ -498,7 +498,7 @@ sub _deleteSession {
value => 0, value => 0,
domain => $self->conf->{domain}, domain => $self->conf->{domain},
secure => 0, secure => 0,
expires => '-1d', expires => 'Wed, 21 Oct 2015 00:00:00 GMT'
) )
) unless ($preserveCookie); ) unless ($preserveCookie);
@ -653,7 +653,8 @@ sub cookie {
$res[0] .= "=$h{value}"; $res[0] .= "=$h{value}";
$h{path} ||= '/'; $h{path} ||= '/';
$h{HttpOnly} //= $self->conf->{httpOnly}; $h{HttpOnly} //= $self->conf->{httpOnly};
$h{expires} //= $self->conf->{cookieExpiration}; $h{max_age} //= $self->conf->{cookieExpiration}
if ( $self->conf->{cookieExpiration} );
foreach (qw(domain path expires max_age HttpOnly)) { foreach (qw(domain path expires max_age HttpOnly)) {
my $f = $_; my $f = $_;
$f =~ s/_/-/g; $f =~ s/_/-/g;

View File

@ -98,11 +98,13 @@ sub storeBrowser {
fingerprint => $fg, fingerprint => $fg,
}, },
); );
# Cookie available 30 days
$req->addCookie( $req->addCookie(
$self->p->cookie( $self->p->cookie(
name => 'llngconnexion', name => 'llngconnexion',
value => $ps->id, value => $ps->id,
expires => '+1M', max_age => 2592000,
) )
); );
} }