|
|
@ -18,19 +18,25 @@ sub auto :Private {
|
|
|
|
|
|
|
|
|
|
|
|
$c->log->debug("*** Root::auto called");
|
|
|
|
$c->log->debug("*** Root::auto called");
|
|
|
|
|
|
|
|
|
|
|
|
if($c->controller =~ /::Root\b/
|
|
|
|
if (
|
|
|
|
or $c->controller =~ /::Login\b/) {
|
|
|
|
__PACKAGE__ eq $c->controller->catalyst_component_name
|
|
|
|
|
|
|
|
or 'NGCP::Panel::Controller::Login' eq $c->controller->catalyst_component_name
|
|
|
|
$c->log->debug("*** Root::auto grant access to " . $c->request->path);
|
|
|
|
or $c->req->uri->path =~ m|^/device/autoprov/.+|
|
|
|
|
return 1;
|
|
|
|
) {
|
|
|
|
} elsif($c->req->uri->path =~ /^\/device\/autoprov\/.+/) {
|
|
|
|
$c->log->debug("*** Root::auto skip authn, grant access to " . $c->request->path);
|
|
|
|
$c->log->debug("*** Root::auto grant access to " . $c->request->path);
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
unless($c->user_exists) {
|
|
|
|
unless($c->user_exists) {
|
|
|
|
$c->log->debug("*** Root::auto user not authenticated");
|
|
|
|
$c->log->debug("*** Root::auto user not authenticated");
|
|
|
|
|
|
|
|
if (
|
|
|
|
|
|
|
|
exists $c->request->env->{SSL_CLIENT_M_SERIAL}
|
|
|
|
|
|
|
|
&& 0 == index $c->controller->catalyst_component_name, 'NGCP::Panel::Controller::API'
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
my $ssl_client_m_serial = hex $c->request->env->{SSL_CLIENT_M_SERIAL};
|
|
|
|
|
|
|
|
$c->authenticate({ ssl_client_m_serial => $ssl_client_m_serial }, 'api_admin');
|
|
|
|
|
|
|
|
$c->detach(qw(API::Root invalid_user), [$ssl_client_m_serial]) unless $c->user_exists;
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
# don't redirect to login page for ajax uris
|
|
|
|
# don't redirect to login page for ajax uris
|
|
|
|
if($c->request->path =~ /\/ajax$/) {
|
|
|
|
if($c->request->path =~ /\/ajax$/) {
|
|
|
|
$c->response->body("403 - Permission denied");
|
|
|
|
$c->response->body("403 - Permission denied");
|
|
|
|