Bug fixes, and AuthN delegation.
Squashed commit of the following: commit 25bc026dc5e0177cd3aa81c11cdace091eb68f36 Author: Oliver Gorwits <oliver@cpan.org> Date: Mon Jun 17 08:16:56 2013 +0100 bump version for new release commit d4042f6e8db42c7a85df4dcf9690fec72ad2db69 Author: Oliver Gorwits <oliver@cpan.org> Date: Sun Jun 16 18:27:52 2013 +0100 Job Queue page play/pause/refresh controls commit b6c9152516d7800409b7a73c5d0cdce6dd405492 Author: Oliver Gorwits <oliver@cpan.org> Date: Sun Jun 16 17:50:06 2013 +0100 limit size of job queue table commit ac9e5feb8b774071fcf4423dd862dced74dee9e6 Author: Oliver Gorwits <oliver@cpan.org> Date: Sun Jun 16 17:47:55 2013 +0100 update bugs link commit 9c0fb0e9aedc6297f4462c3cf88343f6d0df40b6 Author: Oliver Gorwits <oliver@cpan.org> Date: Sun Jun 16 17:41:29 2013 +0100 update MANIFEST commit 7aaa2fff91ed2b1839bdbb79081d90ad3e144f47 Author: Oliver Gorwits <oliver@cpan.org> Date: Sun Jun 16 17:40:35 2013 +0100 Fix Plack middleware config for Expiry commit 313e2cf014cf0da7cf85074e390ad394b28bf42d Author: Oliver Gorwits <oliver@cpan.org> Date: Sun Jun 16 17:23:00 2013 +0100 Support for delegated authentication with REMOTE_USER and X-REMOTE_USER commit 85e21f2bf296c4a5ca6b5afb5091694e56e3031f Author: Oliver Gorwits <oliver@cpan.org> Date: Sun Jun 16 14:24:08 2013 +0100 Add tooltip showing the job queue item logged status message commit 9b14f53ebed51eb46ea278807cfe8a2fbd28743c Author: Oliver Gorwits <oliver@cpan.org> Date: Sun Jun 16 13:43:26 2013 +0100 Increase default frequency of job queue polling to 2 seconds commit 6ba46818d8ab2100c652c8eb8e98bc6f5a54e273 Author: Oliver Gorwits <oliver@cpan.org> Date: Sun Jun 16 12:57:43 2013 +0100 workaround for https://github.com/PerlDancer/Dancer/issues/935 commit c7a2d8a9d45716959bedbbb8db4cdd82a5950642 Author: Oliver Gorwits <oliver@cpan.org> Date: Sun Jun 16 11:54:18 2013 +0100 Fix hyperlinks when running behind reverse proxy on custom path commit 0620efa404bc25cb0a9ada5aa6f1b092d5c4d482 Author: Oliver Gorwits <oliver@cpan.org> Date: Sat Jun 15 18:31:19 2013 +0100 update deploy docs commit 857b1c7aa0fe832f8948349eda5211eb38ba3099 Author: Oliver Gorwits <oliver@cpan.org> Date: Sat Jun 15 18:16:50 2013 +0100 add note about compiler dependency commit 02a2ad6b2c52db9fbc1e24bc8888f658dc7084ad Author: Oliver Gorwits <oliver@cpan.org> Date: Sat Jun 15 17:44:29 2013 +0100 sort vlans, macs, ips in device port view commit 097bad77310728a98b261a2cfca4de7ab50be94b Author: Oliver Gorwits <oliver@cpan.org> Date: Sat Jun 15 16:32:20 2013 +0100 hint when calling web in fg without starman commit 6425d89ddb2b56129c610482134482d8f9455d40 Author: Oliver Gorwits <oliver@cpan.org> Date: Sat Jun 15 15:53:26 2013 +0100 macwalk and arpwalk refactored commit d527b9d05addc82fb38c84f6fea1aa5818fc68d5 Author: Oliver Gorwits <oliver@cpan.org> Date: Thu Jun 13 22:27:34 2013 +0100 implement is_macsuckable and is_arpnipable commit 7af10ed313e25f5d99a22b53ba438225c2259069 Author: Oliver Gorwits <oliver@cpan.org> Date: Thu Jun 13 22:17:39 2013 +0100 version bump commit 8ace3bf8fa48cf3e14bdf86fad5a4862aad50a4b Author: Oliver Gorwits <oliver@cpan.org> Date: Thu Jun 13 22:14:05 2013 +0100 tidy up user menu commit e6eef605c248471dbfe7ec62cd04d73d653523ca Author: Oliver Gorwits <oliver@cpan.org> Date: Thu Jun 13 22:02:52 2013 +0100 Add discoverall, macwalk, arpwalk items to the Admin Tasks menu commit 2631fabd1eccd8a3971e4762eebe57f406623bee Author: Oliver Gorwits <oliver@cpan.org> Date: Thu Jun 13 21:21:50 2013 +0100 remove length() which only became sane in 5.12 commit a7b7169070a58685cacde26a3b6d462e74be9928 Author: Oliver Gorwits <oliver@cpan.org> Date: Thu Jun 13 19:07:56 2013 +0100 Use DBIx::Class new collapsed query support when we can commit 77cddab8ba7033ccb1ecae257bafa4eef8f99f47 Author: Oliver Gorwits <oliver@cpan.org> Date: Wed Jun 12 17:26:47 2013 +0100 Database config simplified to only four essential settings commit 6ed0802bf2ab0fd898ce6945451b8ca6566ae551 Author: Oliver Gorwits <oliver@cpan.org> Date: Wed Jun 12 13:03:20 2013 +0100 Ask to set up guest user for Admin/Port Control rights in deploy script
This commit is contained in:
@@ -74,7 +74,7 @@ foreach my $jobtype (keys %jobs_all, keys %jobs) {
|
||||
if exists $jobs{$jobtype} and not param('device');
|
||||
|
||||
add_job($jobtype, param('device'));
|
||||
redirect uri_for('/admin/jobqueue')->path_query;
|
||||
redirect uri_for('/admin/jobqueue')->as_string;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ get '/admin/*' => sub {
|
||||
my ($tag) = splat;
|
||||
|
||||
if (! eval { var('user')->admin }) {
|
||||
return redirect uri_for('/')->path_query;
|
||||
return redirect uri_for('/')->as_string;
|
||||
}
|
||||
|
||||
# trick the ajax into working as if this were a tabbed page
|
||||
|
||||
@@ -7,10 +7,17 @@ use Digest::MD5 ();
|
||||
|
||||
hook 'before' => sub {
|
||||
if (! session('user') && request->path ne uri_for('/login')->path) {
|
||||
if (setting('no_auth')) {
|
||||
if (setting('trust_x_remote_user') and scalar request->header('X-REMOTE_USER')) {
|
||||
session(user => scalar request->header('X-REMOTE_USER'));
|
||||
}
|
||||
elsif (setting('trust_remote_user') and scalar request->header('REMOTE_USER')) {
|
||||
session(user => scalar request->header('REMOTE_USER'));
|
||||
}
|
||||
elsif (setting('no_auth')) {
|
||||
session(user => 'guest');
|
||||
}
|
||||
else {
|
||||
# user has no AuthN - force to handler for '/'
|
||||
request->path_info('/');
|
||||
}
|
||||
}
|
||||
@@ -27,23 +34,24 @@ hook 'before' => sub {
|
||||
|
||||
post '/login' => sub {
|
||||
if (param('username') and param('password')) {
|
||||
my $user = schema('netdisco')->resultset('User')->find(param('username'));
|
||||
my $user = schema('netdisco')->resultset('User')
|
||||
->find(param('username'));
|
||||
|
||||
if ($user) {
|
||||
my $sum = Digest::MD5::md5_hex(param('password'));
|
||||
if (($sum and $user->password) and ($sum eq $user->password)) {
|
||||
session(user => $user->username);
|
||||
return redirect uri_for('/inventory')->path_query;
|
||||
return redirect uri_for('/inventory')->as_string;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
redirect uri_for('/', {failed => 1})->path_query;
|
||||
redirect uri_for('/', {failed => 1})->as_string;
|
||||
};
|
||||
|
||||
get '/logout' => sub {
|
||||
session->destroy;
|
||||
redirect uri_for('/', {logout => 1})->path_query;
|
||||
redirect uri_for('/', {logout => 1})->as_string;
|
||||
};
|
||||
|
||||
true;
|
||||
|
||||
@@ -116,7 +116,7 @@ get '/device' => sub {
|
||||
});
|
||||
|
||||
if (!defined $dev) {
|
||||
return redirect uri_for('/', {nosuchdevice => 1})->path_query;
|
||||
return redirect uri_for('/', {nosuchdevice => 1})->as_string();
|
||||
}
|
||||
|
||||
params->{'tab'} ||= 'details';
|
||||
|
||||
@@ -22,7 +22,7 @@ config->{engines}->{template_toolkit}->{INCLUDE_PATH} ||= [ setting('views') ];
|
||||
register 'register_template_path' => sub {
|
||||
my ($self, $path) = plugin_args(@_);
|
||||
|
||||
if (!length $path) {
|
||||
if (!$path) {
|
||||
return error "bad template path to register_template_paths";
|
||||
}
|
||||
|
||||
@@ -34,11 +34,11 @@ register 'register_template_path' => sub {
|
||||
sub _register_include {
|
||||
my ($type, $plugin) = @_;
|
||||
|
||||
if (!length $type) {
|
||||
if (!$type) {
|
||||
return error "bad type to _register_include";
|
||||
}
|
||||
|
||||
if (!length $plugin) {
|
||||
if (!$plugin) {
|
||||
return error "bad plugin name to register_$type";
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ register 'register_device_port_column' => sub {
|
||||
$config->{default} ||= '';
|
||||
$config->{position} ||= 'right';
|
||||
|
||||
if (!length $config->{name} or !length $config->{label}) {
|
||||
if (!$config->{name} or !$config->{label}) {
|
||||
return error "bad config to register_device_port_column";
|
||||
}
|
||||
|
||||
@@ -77,9 +77,9 @@ register 'register_device_port_column' => sub {
|
||||
register 'register_navbar_item' => sub {
|
||||
my ($self, $config) = plugin_args(@_);
|
||||
|
||||
if (!length $config->{tag}
|
||||
or !length $config->{path}
|
||||
or !length $config->{label}) {
|
||||
if (!$config->{tag}
|
||||
or !$config->{path}
|
||||
or !$config->{label}) {
|
||||
|
||||
return error "bad config to register_navbar_item";
|
||||
}
|
||||
@@ -97,8 +97,8 @@ register 'register_navbar_item' => sub {
|
||||
register 'register_admin_task' => sub {
|
||||
my ($self, $config) = plugin_args(@_);
|
||||
|
||||
if (!length $config->{tag}
|
||||
or !length $config->{label}) {
|
||||
if (!$config->{tag}
|
||||
or !$config->{label}) {
|
||||
|
||||
return error "bad config to register_admin_task";
|
||||
}
|
||||
@@ -110,8 +110,8 @@ sub _register_tab {
|
||||
my ($nav, $config) = @_;
|
||||
my $stash = setting("_${nav}_tabs");
|
||||
|
||||
if (!length $config->{tag}
|
||||
or !length $config->{label}) {
|
||||
if (!$config->{tag}
|
||||
or !$config->{label}) {
|
||||
|
||||
return error "bad config to register_${nav}_item";
|
||||
}
|
||||
@@ -140,9 +140,9 @@ register 'register_report' => sub {
|
||||
my ($self, $config) = plugin_args(@_);
|
||||
my @categories = @{ setting('_report_order') };
|
||||
|
||||
if (!length $config->{category}
|
||||
or !length $config->{tag}
|
||||
or !length $config->{label}
|
||||
if (!$config->{category}
|
||||
or !$config->{tag}
|
||||
or !$config->{label}
|
||||
or 0 == scalar grep {$config->{category} eq $_} @categories) {
|
||||
|
||||
return error "bad config to register_report";
|
||||
|
||||
@@ -13,7 +13,7 @@ register_admin_task({
|
||||
|
||||
ajax '/ajax/control/admin/jobqueue/del' => sub {
|
||||
send_error('Forbidden', 403) unless var('user')->admin;
|
||||
send_error('Missing job', 400) unless length param('job');
|
||||
send_error('Missing job', 400) unless param('job');
|
||||
|
||||
schema('netdisco')->txn_do(sub {
|
||||
my $device = schema('netdisco')->resultset('Admin')
|
||||
@@ -26,7 +26,10 @@ ajax '/ajax/content/admin/jobqueue' => sub {
|
||||
|
||||
my $set = schema('netdisco')->resultset('Admin')
|
||||
->with_times
|
||||
->search({}, {order_by => { -desc => [qw/entered device action/] }});
|
||||
->search({}, {
|
||||
order_by => { -desc => [qw/entered device action/] },
|
||||
rows => 200,
|
||||
});
|
||||
|
||||
content_type('text/html');
|
||||
template 'ajax/admintask/jobqueue.tt', {
|
||||
|
||||
@@ -15,14 +15,14 @@ register_admin_task({
|
||||
sub _sanity_ok {
|
||||
return 0 unless var('user') and var('user')->admin;
|
||||
|
||||
return 0 unless length param('dns')
|
||||
return 0 unless param('dns')
|
||||
and param('dns') =~ m/^[[:print:]]+$/
|
||||
and param('dns') !~ m/[[:space:]]/;
|
||||
|
||||
my $ip = NetAddr::IP::Lite->new(param('ip'));
|
||||
return 0 unless ($ip and$ip->addr ne '0.0.0.0');
|
||||
|
||||
return 0 unless length param('ports')
|
||||
return 0 unless param('ports')
|
||||
and param('ports') =~ m/^[[:digit:]]+$/;
|
||||
|
||||
return 1;
|
||||
|
||||
@@ -21,8 +21,8 @@ sub _sanity_ok {
|
||||
my $dev2 = NetAddr::IP::Lite->new(param('dev2'));
|
||||
return 0 unless ($dev2 and $dev2->addr ne '0.0.0.0');
|
||||
|
||||
return 0 unless length param('port1');
|
||||
return 0 unless length param('port2');
|
||||
return 0 unless param('port1');
|
||||
return 0 unless param('port2');
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -57,8 +57,15 @@ ajax '/ajax/content/device/ports' => sub {
|
||||
# get number of vlans on the port to control whether to list them or not
|
||||
$set = $set->with_vlan_count if param('c_vmember');
|
||||
|
||||
# run single collapsed query for all relations, but only if we're not
|
||||
# also fetching archived data (tests show it's better this way)
|
||||
$set = $set->search_rs({}, { prefetch => [{ port_vlans_tagged => 'vlan'}] })
|
||||
if param('c_vmember') and not (param('c_nodes') and param('n_archived'));
|
||||
|
||||
# what kind of nodes are we interested in?
|
||||
my $nodes_name = (param('n_archived') ? 'nodes' : 'active_nodes');
|
||||
$set = $set->search_rs({}, { order_by => ["${nodes_name}.mac", "ips.ip"] })
|
||||
if param('c_nodes');
|
||||
$nodes_name .= '_with_age' if param('c_nodes') and param('n_age');
|
||||
|
||||
# retrieve active/all connected nodes, if asked for
|
||||
|
||||
@@ -60,6 +60,7 @@ ajax '/ajax/content/search/node' => sub {
|
||||
->search_by_dns({dns => $node, @active});
|
||||
}
|
||||
return unless $set and $set->count;
|
||||
$set = $set->search_rs({}, { order_by => 'me.mac' });
|
||||
|
||||
template 'ajax/search/node_by_ip.tt', {
|
||||
macs => $set,
|
||||
|
||||
@@ -65,7 +65,7 @@ get '/search' => sub {
|
||||
|
||||
if (not param('tab')) {
|
||||
if (not $q) {
|
||||
return redirect uri_for('/')->path_query;
|
||||
return redirect uri_for('/')->as_string;
|
||||
}
|
||||
|
||||
# pick most likely tab for initial results
|
||||
@@ -82,7 +82,7 @@ get '/search' => sub {
|
||||
tab => 'details',
|
||||
q => ($nd->first->dns || $nd->first->ip),
|
||||
f => '',
|
||||
})->path_query;
|
||||
})->as_string;
|
||||
}
|
||||
|
||||
# multiple devices
|
||||
|
||||
@@ -35,7 +35,7 @@ ajax '/ajax/data/deviceip/typeahead' => sub {
|
||||
ajax '/ajax/data/port/typeahead' => sub {
|
||||
my $dev = param('dev1') || param('dev2');
|
||||
my $port = param('port1') || param('port2');
|
||||
send_error('Missing device', 400) unless length $dev;
|
||||
send_error('Missing device', 400) unless $dev;
|
||||
|
||||
my $device = schema('netdisco')->resultset('Device')
|
||||
->find({ip => $dev});
|
||||
@@ -43,7 +43,7 @@ ajax '/ajax/data/port/typeahead' => sub {
|
||||
|
||||
my $set = $device->ports({},{order_by => 'port'});
|
||||
$set = $set->search({port => { -ilike => "\%$port\%" }})
|
||||
if length $port;
|
||||
if $port;
|
||||
|
||||
my $results = [ sort { &App::Netdisco::Util::Web::sort_port($a->port, $b->port) } $set->all ];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user