Make user_info_class and user_verify_class values dynamic

(also allows to remove FOF_Sudo from Bugzilla::Config::Auth)
hinted-selects
Vitaliy Filippov 2014-10-20 14:19:14 +04:00
parent fe19b5071a
commit 4fdb5c0a72
4 changed files with 28 additions and 25 deletions

View File

@ -31,6 +31,7 @@ package Bugzilla::Config::Auth;
use strict;
use Bugzilla::Util;
use Bugzilla::Config::Common;
our $sortkey = 300;
@ -96,18 +97,10 @@ sub get_param_list
default => '',
},
# XXX in the future:
#
# user_verify_class and user_info_class should have choices gathered from
# whatever sits in their respective directories
#
# rather than comma-separated lists, these two should eventually become
# arrays, but that requires alterations to editparams first
{
name => 'user_info_class',
type => 's',
choices => [ 'CGI', 'Env', 'Env,CGI', 'FOF_Sudo,CGI', 'FOF_Sudo,Env,CGI' ],
type => 'o',
choices => get_subclasses('Bugzilla::Auth::Login'),
default => 'CGI',
checker => \&check_multi
},
@ -115,7 +108,7 @@ sub get_param_list
{
name => 'user_verify_class',
type => 'o',
choices => [ 'DB', 'RADIUS', 'LDAP' ],
choices => get_subclasses('Bugzilla::Auth::Verify'),
default => 'DB',
checker => \&check_user_verify_class
},

View File

@ -32,7 +32,7 @@ use Pod::Usage;
use Bugzilla::Constants;
use Bugzilla::JobQueue;
use Bugzilla::Util qw(get_text);
use Bugzilla::Util qw(get_text get_subclasses);
BEGIN { eval "use base qw(Daemon::Generic)"; }
our $VERSION = BUGZILLA_VERSION;
@ -217,20 +217,10 @@ sub gd_run
my $jq = Bugzilla->job_queue();
$jq->set_verbose($self->{debug});
my $seen = {};
foreach my $path (@INC)
foreach my $module (@{ get_subclasses("Bugzilla::Job") })
{
foreach my $file (<$path/Bugzilla/Job/*.pm>)
{
$file = substr($file, 1 + length $path, -3);
$file =~ s!/!::!gs;
$seen->{$file} = 1;
}
}
foreach my $module (keys %$seen)
{
eval "use $module";
$jq->can_do($module);
eval "use Bugzilla::Job::$module";
$jq->can_do("Bugzilla::Job::$module");
}
$jq->work;
}

View File

@ -45,6 +45,7 @@ use base qw(Exporter);
get_text disable_utf8 bz_encode_json
xml_element xml_element_quote xml_dump_simple xml_simple
Dumper http_build_query http_decode_query join_escaped split_escaped
get_subclasses
);
use Bugzilla::Constants;
@ -1023,6 +1024,23 @@ sub split_escaped
return @r;
}
sub get_subclasses
{
my ($pkg) = @_;
$pkg =~ s/::/\//gso;
my $seen = {};
foreach my $path (@INC)
{
foreach my $file (glob("$path/$pkg/*.pm"))
{
$file = substr($file, 2 + length($pkg) + length($path), -3);
$file =~ s!/!::!gs;
$seen->{$file} = 1;
}
}
return [ sort keys %$seen ];
}
1;
__END__

View File

@ -84,6 +84,8 @@ Refactoring:
* Merge create/edit templates for milestones, versions, field values, keywords, classifications.
* Remove JOB_MAP hardcode that didn't allow to add custom job classes without
modifying the core code.
* Remove parameter value hardcode that didn't allow to add custom auth modules
without modifying the core code.
* Remove various procedural and/or unused APIs from Bugzilla modules,
(like is_open_state, BUG_STATE_OPEN, closed_bug_statuses, LookupNamedQuery...)
* Remove some unused functions and filters from Bugzilla::Template.