From 70540fb131c58cf4fb012854759eef2d73528a30 Mon Sep 17 00:00:00 2001 From: "mkanat%bugzilla.org" <> Date: Thu, 7 Aug 2008 04:38:22 +0000 Subject: Bug 438435: Need code hooks for authentication Patch By Max Kanat-Alexander r=LpSolit, a=mkanat --- Bugzilla/Auth/Login/Stack.pm | 16 ++++++++++++---- Bugzilla/Auth/Verify/Stack.pm | 16 ++++++++++++---- 2 files changed, 24 insertions(+), 8 deletions(-) (limited to 'Bugzilla/Auth') diff --git a/Bugzilla/Auth/Login/Stack.pm b/Bugzilla/Auth/Login/Stack.pm index d51003861..ab9a93bce 100644 --- a/Bugzilla/Auth/Login/Stack.pm +++ b/Bugzilla/Auth/Login/Stack.pm @@ -26,16 +26,24 @@ use fields qw( _stack successful ); +use Hash::Util qw(lock_keys); +use Bugzilla::Hook; sub new { my $class = shift; my $self = $class->SUPER::new(@_); my $list = shift; + my %methods = map { $_ => "Bugzilla/Auth/Login/$_.pm" } split(',', $list); + lock_keys(%methods); + Bugzilla::Hook::process('auth-login_methods', { modules => \%methods }); + $self->{_stack} = []; - foreach my $login_method (split(',', $list)) { - require "Bugzilla/Auth/Login/${login_method}.pm"; - push(@{$self->{_stack}}, - "Bugzilla::Auth::Login::$login_method"->new(@_)); + foreach my $login_method (keys %methods) { + my $module = $methods{$login_method}; + require $module; + $module =~ s|/|::|g; + $module =~ s/.pm$//; + push(@{$self->{_stack}}, $module->new(@_)); } return $self; } diff --git a/Bugzilla/Auth/Verify/Stack.pm b/Bugzilla/Auth/Verify/Stack.pm index 577b5a22f..0ddb9a441 100644 --- a/Bugzilla/Auth/Verify/Stack.pm +++ b/Bugzilla/Auth/Verify/Stack.pm @@ -21,16 +21,24 @@ use fields qw( _stack successful ); +use Hash::Util qw(lock_keys); +use Bugzilla::Hook; sub new { my $class = shift; my $list = shift; my $self = $class->SUPER::new(@_); + my %methods = map { $_ => "Bugzilla/Auth/Verify/$_.pm" } split(',', $list); + lock_keys(%methods); + Bugzilla::Hook::process('auth-verify_methods', { modules => \%methods }); + $self->{_stack} = []; - foreach my $verify_method (split(',', $list)) { - require "Bugzilla/Auth/Verify/${verify_method}.pm"; - push(@{$self->{_stack}}, - "Bugzilla::Auth::Verify::$verify_method"->new(@_)); + foreach my $verify_method (keys %methods) { + my $module = $methods{$verify_method}; + require $module; + $module =~ s|/|::|g; + $module =~ s/.pm$//; + push(@{$self->{_stack}}, $module->new(@_)); } return $self; } -- cgit v1.2.3-24-g4f1b