blob: f94c54446b54505d701c6a6246c6347d8e2dc4ea (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This Source Code Form is "Incompatible With Secondary Licenses", as
# defined by the Mozilla Public License, v. 2.0.
package Bugzilla::Extension::Persona;
use 5.10.1;
use strict;
use warnings;
use base qw(Bugzilla::Extension);
use Bugzilla::Config qw(SetParam write_params);
our $VERSION = '0.01';
sub install_update_db {
# The extension changed from BrowserID to Persona
# so we need to update user_info_class if this system
# was using BrowserID for verification.
my $params = Bugzilla->params || Bugzilla::Config::read_param_file();
my $user_info_class = $params->{'user_info_class'};
if ($user_info_class =~ /BrowserID/) {
$user_info_class =~ s/BrowserID/Persona/;
SetParam('user_info_class', $user_info_class);
write_params();
}
}
sub auth_login_methods {
my ($self, $args) = @_;
my $modules = $args->{'modules'};
if (exists($modules->{'Persona'})) {
$modules->{'Persona'} = 'Bugzilla/Extension/Persona/Login.pm';
}
}
sub config_modify_panels {
my ($self, $args) = @_;
my $panels = $args->{'panels'};
my $auth_panel_params = $panels->{'auth'}->{'params'};
my ($user_info_class) =
grep { $_->{'name'} eq 'user_info_class' } @$auth_panel_params;
if ($user_info_class) {
push(@{ $user_info_class->{'choices'} }, "Persona,CGI");
}
# The extension changed from BrowserID to Persona
# so we need to retain the current values for the new
# params that will be created.
my $params = Bugzilla->params || Bugzilla::Config::read_param_file();
my $verify_url = $params->{'browserid_verify_url'};
my $includejs_url = $params->{'browserid_includejs_url'};
if ($verify_url && $includejs_url) {
foreach my $param (@{ $panels->{'persona'}->{'params'} }) {
if ($param->{'name'} eq 'persona_verify_url') {
$param->{'default'} = $verify_url;
}
if ($param->{'name'} eq 'persona_includejs_url') {
$param->{'default'} = $includejs_url;
}
}
}
}
sub attachment_should_redirect_login {
my ($self, $args) = @_;
my $cgi = Bugzilla->cgi;
if ($cgi->param("persona_assertion")) {
${$args->{do_redirect}} = 1;
}
}
sub config_add_panels {
my ($self, $args) = @_;
my $modules = $args->{panel_modules};
$modules->{Persona} = "Bugzilla::Extension::Persona::Config";
}
__PACKAGE__->NAME;
|