]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 173761 Need ability to always require login
authorbugreport%peshkin.net <>
Wed, 27 Nov 2002 22:46:05 +0000 (22:46 +0000)
committerbugreport%peshkin.net <>
Wed, 27 Nov 2002 22:46:05 +0000 (22:46 +0000)
patch by joel
r=gerv, a=justdave

CGI.pl
defparams.pl
index.cgi
token.cgi

diff --git a/CGI.pl b/CGI.pl
index 84c54ad6d69b30ad413a54b7072373364e3db0dd..24f92c072fd88305e84553e72aaa95745dd0d745 100644 (file)
--- a/CGI.pl
+++ b/CGI.pl
@@ -219,7 +219,14 @@ sub get_netaddr {
     return join(".", unpack("CCCC", pack("N", $addr)));
 }
 
-sub quietly_check_login() {
+my $login_cookie_set = 0;
+# If quietly_check_login is called with no arguments and logins are
+# required, it will prompt for a login.
+sub quietly_check_login {
+    if (Param('requirelogin') && !(@_)) {
+        confirm_login();
+        return;
+    }
     $::disabledreason = '';
     my $userid = 0;
     my $ipaddr = $ENV{'REMOTE_ADDR'};
@@ -561,11 +568,19 @@ sub confirm_login {
 
        $::COOKIE{"Bugzilla_logincookie"} = $logincookie;
        my $cookiepath = Param("cookiepath");
-       print "Set-Cookie: Bugzilla_login= " . url_quote($enteredlogin) . " ; path=$cookiepath; expires=Sun, 30-Jun-2029 00:00:00 GMT\n";
-       print "Set-Cookie: Bugzilla_logincookie=$logincookie ; path=$cookiepath; expires=Sun, 30-Jun-2029 00:00:00 GMT\n";
+       if ($login_cookie_set == 0) {
+           $login_cookie_set = 1;
+           print "Set-Cookie: Bugzilla_login= " . url_quote($enteredlogin) . " ; path=$cookiepath; expires=Sun, 30-Jun-2029 00:00:00 GMT\n";
+           print "Set-Cookie: Bugzilla_logincookie=$logincookie ; path=$cookiepath; expires=Sun, 30-Jun-2029 00:00:00 GMT\n";
+       }
     }
 
-    $userid = quietly_check_login();
+    # If anonymous logins are disabled, quietly_check_login will force
+    # the user to log in by calling confirm_login() when called by any 
+    # code that does not call it with an argument. When confirm_login
+    # calls quietly_check_login, it must not result in confirm_login
+    # being called back.
+    $userid = quietly_check_login('do_not_recurse_here');
 
     if (!$userid) {
         if ($::disabledreason) {
index b0567c78304103f76b3e94e588cf023d34accb43..ae09232951254428c53d4ca65e07ba89ca2075c7 100644 (file)
@@ -963,6 +963,15 @@ Reason: %reason%
    checker => \&check_netmask
   },
 
+  {
+   name => 'requirelogin',
+   desc => 'If this option is set, all access to the system beyond the ' .
+           ' front page will require a login. No anonymous users will ' .
+           ' be permitted.',
+   type => 'b',
+   default => '0'
+  },
+
   {
    name => 'usermatchmode',
    desc => 'Allow match strings to be entered for user names when entering ' .
index 7e9fb5aab8484104cc159a16096236e70810df9b..f6e11ac21906781a3056f5b7e703410ea04eb875 100755 (executable)
--- a/index.cgi
+++ b/index.cgi
@@ -45,7 +45,7 @@ use vars qw(
 ConnectToDatabase();
 
 # Check whether or not the user is logged in and, if so, set the $::userid 
-quietly_check_login();
+quietly_check_login('permit_anonymous');
 
 ###############################################################################
 # Main Body Execution
index d4055d058d0c5e73295fc2e2f100a93e76a58dea..9a7efb5c5a2a1cf1ed8e8ded655dbc8f32645e94 100755 (executable)
--- a/token.cgi
+++ b/token.cgi
@@ -36,7 +36,7 @@ require "CGI.pl";
 
 # Establish a connection to the database backend.
 ConnectToDatabase();
-quietly_check_login();
+quietly_check_login('permit_anonymous');
 
 # Use the "Token" module that contains functions for doing various
 # token-related tasks.