explicitly use SameSite=Lax Cookie Attribute for dancer.session cookies

This commit is contained in:
Oliver Gorwits
2023-06-28 16:39:24 +01:00
parent 9f4401f2fb
commit ef4e3f5181
2 changed files with 22 additions and 0 deletions

View File

@@ -99,6 +99,27 @@ BEGIN {
}
return $self->{path};
};
# implement same_site
# from https://github.com/PerlDancer/Dancer-Session-Cookie/issues/20
*Dancer::Session::Cookie::_cookie_params = sub {
my $self = shift;
my $name = $self->session_name;
my $duration = $self->_session_expires_as_duration;
my %cookie = (
name => $name,
value => $self->_cookie_value,
path => setting('session_cookie_path') || '/',
domain => setting('session_domain'),
secure => setting('session_secure'),
http_only => setting("session_is_http_only") // 1,
same_site => setting("session_same_site"),
);
if ( defined $duration ) {
$cookie{expires} = time + $duration;
}
return %cookie;
};
}
use App::Netdisco::Web::AuthN;

View File

@@ -640,6 +640,7 @@ plugins:
schema_name: 'netdisco'
session: 'cookie'
session_cookie_key: 'this_will_be_overridden_on_webapp_startup'
session_same_site: 'Lax'
template: 'netdisco_template_toolkit'
route_cache: true
appname: 'Netdisco'