Bug 34478: Check CSRF in get_template_and_user
Not sure this is the right place in get_template_and_user Will have to test login and 2FA Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
parent
4ed5bf19a7
commit
a0dcce9ce1
26
C4/Auth.pm
26
C4/Auth.pm
|
|
@ -947,6 +947,8 @@ sub checkauth {
|
|||
}
|
||||
}
|
||||
|
||||
my $request_method = $query->request_method // q{};
|
||||
|
||||
if ( $auth_state eq 'failed' || $logout ) {
|
||||
$sessionID = undef;
|
||||
$userid = undef;
|
||||
|
|
@ -1090,7 +1092,6 @@ sub checkauth {
|
|||
}
|
||||
else {
|
||||
my $retuserid;
|
||||
my $request_method = $query->request_method // q{};
|
||||
|
||||
if (
|
||||
$request_method eq 'POST'
|
||||
|
|
@ -1480,6 +1481,29 @@ sub checkauth {
|
|||
}
|
||||
}
|
||||
|
||||
if ( $auth_state eq 'completed' && defined $query->param('op') ) {
|
||||
die "Cannot use GET for this request"
|
||||
if $request_method ne 'POST';
|
||||
|
||||
print $query->header(
|
||||
{
|
||||
type => 'text/html',
|
||||
charset => 'utf-8',
|
||||
cookie => $cookie,
|
||||
'X-Frame-Options' => 'SAMEORIGIN',
|
||||
-sameSite => 'Lax'
|
||||
}
|
||||
);
|
||||
|
||||
output_and_exit( $query, $cookie, $template, 'wrong_csrf_token' )
|
||||
unless Koha::Token->new->check_csrf(
|
||||
{
|
||||
session_id => scalar $query->cookie('CGISESSID'),
|
||||
token => scalar $query->param('csrf_token'),
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
$template->param(
|
||||
LibraryName => C4::Context->preference("LibraryName"),
|
||||
%info,
|
||||
|
|
|
|||
Loading…
Reference in New Issue