From a1ea5c578a64fba5e6ee629f22b81642c32c22f7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bernd=20Ble=C3=9Fmann?= Date: Fri, 25 Oct 2019 15:09:46 +0200 Subject: [PATCH] =?utf8?q?Login:=20blacklisting=20bei=20Callback=20f=C3=BC?= =?utf8?q?r=20Redirect=20zum=20Ziel=20implementiert?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/Dispatcher.pm | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/SL/Dispatcher.pm b/SL/Dispatcher.pm index 16337b24e..9aeecfc64 100644 --- a/SL/Dispatcher.pm +++ b/SL/Dispatcher.pm @@ -402,6 +402,7 @@ sub handle_login_error { if ( $action =~ m/LoginScreen\/user_login/ && $params{action} && 'get' eq lc($ENV{REQUEST_METHOD}) + && !_is_callback_blacklisted(map {$_ => $params{$_}} qw(routing_type script controller action) ) ) { require SL::Controller::Base; @@ -419,6 +420,48 @@ sub handle_login_error { $self->end_request; } +sub _is_callback_blacklisted { + my (%params) = @_; + + # You can give a name only, then all actions are blackisted. + # Or you can give name and action, then only this action is blacklisted + # examples: + # {name => 'is', action => 'edit'} + # {name => 'Project', action => 'edit'}, + my @script_blacklist = ( + {name => 'admin'}, + {name => 'login'}, + ); + + my @controller_blacklist = ( + {name => 'Admin'}, + {name => 'LoginScreen'}, + ); + + my ($name, $blacklist); + if ('old' eq ($params{routing_type} // '')) { + $name = $params{script}; + $blacklist = \@script_blacklist; + } else { + $name = $params{controller}; + $blacklist = \@controller_blacklist; + } + + foreach my $bl (@$blacklist) { + return 1 if _is_name_action_blacklisted($bl->{name}, $bl->{action}, $name, $params{action}); + } + + return; +} + +sub _is_name_action_blacklisted { + my ($blacklisted_name, $blacklisted_action, $name, $action) = @_; + + return 1 if ($name // '') eq $blacklisted_name && !$blacklisted_action; + return 1 if ($name // '') eq $blacklisted_name && ($action // '') eq $blacklisted_action; + return; +} + sub unrequire_bin_mozilla { my $self = shift; return unless $self->_interface_is_fcgi; -- 2.20.1