68
# Redirect to SSL if required
68
# Redirect to SSL if required
69
if (Bugzilla->params->{'sslbase'} ne ''
69
Bugzilla->cgi->require_https(Bugzilla->params->{'sslbase'})
70
and Bugzilla->params->{'ssl'} ne 'never')
70
if ssl_require_redirect();
72
$cgi->require_https(Bugzilla->params->{'sslbase'});
74
print $cgi->header();
72
print $cgi->header();
75
$template->process("account/auth/login.html.tmpl",
73
$template->process("account/auth/login.html.tmpl",
76
{ 'target' => $cgi->url(-relative=>1) })
74
{ 'target' => $cgi->url(-relative=>1) })
72
$self->charset(Bugzilla->params->{'utf8'} ? 'UTF-8' : '');
72
$self->charset(Bugzilla->params->{'utf8'} ? 'UTF-8' : '');
74
# Redirect to SSL if required
74
# Redirect to SSL if required
75
if (Bugzilla->params->{'sslbase'} ne ''
75
if (i_am_cgi() && Bugzilla->usage_mode != USAGE_MODE_WEBSERVICE
76
&& Bugzilla->params->{'ssl'} eq 'always'
76
&& ssl_require_redirect())
79
$self->require_https(Bugzilla->params->{'sslbase'});
78
$self->require_https(Bugzilla->params->{'sslbase'});
298
# Redirect to https if required
297
# Redirect to https if required
299
sub require_https {
298
sub require_https {
300
my $self = shift;
299
my ($self, $url) = @_;
301
if ($self->protocol ne 'https') {
300
# Do not create query string if data submitted via XMLRPC
302
my $url = shift;
301
my $query = Bugzilla->usage_mode == USAGE_MODE_WEBSERVICE ? 0 : 1;
303
if (defined $url) {
302
# XMLRPC clients (SOAP::Lite at least) requires 301 to redirect properly
304
$url .= $self->url('-path_info' => 1, '-query' => 1, '-relative' => 1);
303
my $status = Bugzilla->usage_mode == USAGE_MODE_WEBSERVICE ? 301 : 302;
305
} else {
304
if (defined $url) {
306
$url = $self->self_url;
305
$url .= $self->url('-path_info' => 1, '-query' => $query, '-relative' => 1);
307
$url =~ s/^http:/https:/i;
306
} else {
308
}
307
$url = $self->self_url;
309
print $self->redirect(-location => $url);
308
$url =~ s/^http:/https:/i;
310
print $self->redirect(-location => $url, -status => $status). "\n";
378
This routine checks if the current page is being served over https, and
378
This routine checks if the current page is being served over https, and
379
redirects to the https protocol if required, retaining QUERY_STRING.
379
redirects to the https protocol if required, retaining QUERY_STRING.
381
It takes an option argument which will be used as the base URL. If $baseurl
381
It takes an optional argument which will be used as the base URL. If $baseurl
382
is not provided, the current URL is used.
382
is not provided, the current URL is used.
36
html_quote url_quote xml_quote
36
html_quote url_quote xml_quote
37
css_class_quote html_light_quote url_decode
37
css_class_quote html_light_quote url_decode
38
i_am_cgi get_netaddr correct_urlbase
38
i_am_cgi get_netaddr correct_urlbase
39
lsearch
39
lsearch ssl_require_redirect
40
diff_arrays diff_strings
40
diff_arrays diff_strings
41
trim wrap_hard wrap_comment find_wrap_point
41
trim wrap_hard wrap_comment find_wrap_point
42
format_time format_time_decimal validate_date
42
format_time format_time_decimal validate_date
218
return exists $ENV{'SERVER_SOFTWARE'} ? 1 : 0;
218
return exists $ENV{'SERVER_SOFTWARE'} ? 1 : 0;
221
sub ssl_require_redirect {
224
# Redirect to SSL if required.
225
if (!(uc($ENV{HTTPS}) eq 'ON' || $ENV{'SERVER_PORT'} == 443)
226
&& Bugzilla->params->{'sslbase'} ne '')
228
if (Bugzilla->params->{'ssl'} eq 'always'
229
|| (Bugzilla->params->{'ssl'} eq 'authenticated sessions'
230
&& Bugzilla->user->id)
231
|| (Bugzilla->params->{'ssl'} eq 'authenticated sessions'
232
&& !Bugzilla->user->id && $method eq 'User.login'))
221
sub correct_urlbase {
241
sub correct_urlbase {
222
my $ssl = Bugzilla->params->{'ssl'};
242
my $ssl = Bugzilla->params->{'ssl'};
223
return Bugzilla->params->{'urlbase'} if $ssl eq 'never';
243
return Bugzilla->params->{'urlbase'} if $ssl eq 'never';
20
use strict;
20
use strict;
21
use Bugzilla::WebService::Constants;
21
use Bugzilla::WebService::Constants;
22
use Date::Parse;
23
use Date::Parse;
23
use XMLRPC::Lite;
24
use XMLRPC::Lite;
59
my ($action, $uri, $method) = @_;
60
my $full_method = $uri . "." . $method;
62
# Redirect to SSL if required.
63
Bugzilla->cgi->require_https(Bugzilla->params->{'sslbase'})
64
if ssl_require_redirect($full_method);
57
# For some methods, we shouldn't call Bugzilla->login before we call them
67
# For some methods, we shouldn't call Bugzilla->login before we call them
58
use constant LOGIN_EXEMPT => { };
68
use constant LOGIN_EXEMPT => { };
35
use Bugzilla::Constants;
35
use Bugzilla::Constants;
36
use Bugzilla::Error;
36
use Bugzilla::Error;
37
use Bugzilla::Update;
37
use Bugzilla::Update;
39
# Check whether or not the user is logged in
40
# Check whether or not the user is logged in
40
my $user = Bugzilla->login(LOGIN_OPTIONAL);
41
my $user = Bugzilla->login(LOGIN_OPTIONAL);
46
my $cgi = Bugzilla->cgi;
47
my $cgi = Bugzilla->cgi;
47
# Force to use HTTPS unless Bugzilla->params->{'ssl'} equals 'never'.
48
# Force to use HTTPS unless Bugzilla->params->{'ssl'} equals 'never'.
48
# This is required because the user may want to log in from here.
49
# This is required because the user may want to log in from here.
49
if (Bugzilla->params->{'sslbase'} ne '' and Bugzilla->params->{'ssl'} ne 'never') {
50
$cgi->require_https(Bugzilla->params->{'sslbase'})
50
$cgi->require_https(Bugzilla->params->{'sslbase'});
51
if ssl_require_redirect();
53
my $template = Bugzilla->template;
53
my $template = Bugzilla->template;
54
my $vars = {};
54
my $vars = {};
347
$vars->{'date'} = str2time($date);
347
$vars->{'date'} = str2time($date);
349
# We require a HTTPS connection if possible.
349
# We require a HTTPS connection if possible.
350
if (Bugzilla->params->{'sslbase'} ne ''
350
Bugzilla->cgi->require_https(Bugzilla->params->{'sslbase'})
351
&& Bugzilla->params->{'ssl'} ne 'never')
351
if ssl_require_redirect();
353
$cgi->require_https(Bugzilla->params->{'sslbase'});
355
print $cgi->header();
353
print $cgi->header();
357
$template->process('account/email/confirm-new.html.tmpl', $vars)
355
$template->process('account/email/confirm-new.html.tmpl', $vars)
54
my $response = Bugzilla::WebService::XMLRPC::Transport::HTTP::CGI
54
my $response = Bugzilla::WebService::XMLRPC::Transport::HTTP::CGI
55
->dispatch_with($dispatch)
55
->dispatch_with($dispatch)
56
->on_action(sub { Bugzilla::WebService::handle_login($dispatch, @_) } )
56
->on_action(sub {
57
my ($action, $uri, $method) = @_;
58
Bugzilla::WebService::handle_login($dispatch, @_);
59
Bugzilla::WebService::handle_redirect(@_);
57
->handle;
61
->handle;