Skip to content

Commit d53a7e4

Browse files
committed
Add x_csrf_and_mfa_protection helper
1 parent a3c6f7a commit d53a7e4

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

lib/pause_2017/PAUSE/Web.pm

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,9 @@ sub startup {
8181
my $action = $app->pause->config->action($name);
8282
for my $method (qw/get post/) {
8383
my $route = $private->$method("/$name");
84-
$route->with_csrf_protection if $method eq "post" and $action->{x_csrf_protection};
85-
$route->with_mfa_protection if $method eq "post" and $action->{x_mfa_protection};
84+
$route->with_csrf_protection if $method eq "post" and $action->{x_csrf_protection};
85+
$route->with_mfa_protection if $method eq "post" and $action->{x_mfa_protection};
86+
$route->with_csrf_and_mfa_protection if $method eq "post" and $action->{x_csrf_and_mfa_protection};
8687
$route->to($action->{x_mojo_to});
8788
}
8889
}

lib/pause_2017/PAUSE/Web/Config.pm

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -428,8 +428,7 @@ our %Actions = (
428428
cat => "User/06Account/02",
429429
desc => "Change your password any time you want.",
430430
method => 'POST',
431-
x_csrf_protection => 1,
432-
x_mfa_protection => 1,
431+
x_csrf_and_mfa_protection => 1,
433432
x_form => {
434433
HIDDENNAME => {form_type => "hidden_field"},
435434
ABRA => {form_type => "hidden_field"},
@@ -445,8 +444,7 @@ our %Actions = (
445444
cat => "User/06Account/01",
446445
desc => "Edit your user name, your email addresses (both public and secret one), change the URL of your homepage.",
447446
method => 'POST',
448-
x_csrf_protection => 1,
449-
x_mfa_protection => 1,
447+
x_csrf_and_mfa_protection => 1,
450448
x_form => {
451449
HIDDENNAME => {form_type => "hidden_field"},
452450
pause99_edit_cred_fullname => {form_type => "text_field"},

lib/pause_2017/PAUSE/Web/Plugin/WithMFAProtection.pm

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,13 @@ sub register {
8080
}
8181
);
8282

83+
$routes->add_shortcut(
84+
with_csrf_and_mfa_protection => sub {
85+
my ($route) = @_;
86+
return $route->requires( with_csrf_protection => 1, with_mfa_protection => 1 );
87+
}
88+
);
89+
8390
return;
8491
}
8592

0 commit comments

Comments
 (0)