]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 1402894 - Remove "Restrict this session to this IP" option from login page
authorKohei Yoshino <kohei.yoshino@gmail.com>
Thu, 14 Feb 2019 21:43:07 +0000 (16:43 -0500)
committerGitHub <noreply@github.com>
Thu, 14 Feb 2019 21:43:07 +0000 (16:43 -0500)
16 files changed:
Bugzilla/App/Plugin/Glue.pm
Bugzilla/Auth.pm
Bugzilla/Auth/Login/Cookie.pm
Bugzilla/Auth/Persist/Cookie.pm
Bugzilla/DB/Schema.pm
Bugzilla/Install/DB.pm
Bugzilla/User/Session.pm
Bugzilla/WebService.pm
docs/en/rst/api/core/v1/general.rst
docs/en/rst/api/core/v1/user.rst
sanitycheck.cgi
skins/standard/global.css
skins/standard/mobile.css
t/mojo-oauth2.t
template/en/default/account/auth/login.html.tmpl
template/en/default/account/prefs/sessions.html.tmpl

index 6e28528a893ffe45dd877985cd44e05a60c55170..b8b0c20bd1893308e275ccf9492f728cfa8828f8 100644 (file)
@@ -99,19 +99,13 @@ sub register {
 
       my $login_cookie = $c->cookie("Bugzilla_logincookie");
       my $user_id      = $c->cookie("Bugzilla_login");
-      my $ip_addr      = $c->tx->remote_address;
 
       return $c->bugzilla->login_redirect_if_required($type)
         unless ($login_cookie && $user_id);
 
       my $db_cookie = Bugzilla->dbh->selectrow_array(
-        q{
-                    SELECT cookie
-                      FROM logincookies
-                     WHERE cookie = ?
-                           AND userid = ?
-                           AND (restrict_ipaddr = 0 OR ipaddr = ?)
-                }, undef, ($login_cookie, $user_id, $ip_addr)
+        'SELECT cookie FROM logincookies WHERE cookie = ? AND userid = ?',
+        undef, ($login_cookie, $user_id)
       );
 
       if (defined $db_cookie && secure_compare($login_cookie, $db_cookie)) {
index c40b3582e755d17e918923f3cbdd8b8165a8ab41..868d04c038d9ca680977da620bfb31da593b2bc0 100644 (file)
@@ -93,7 +93,7 @@ sub login {
     my $cgi    = Bugzilla->cgi;
     my $uri    = URI->new($cgi->self_url);
     foreach
-      my $param (qw( Bugzilla_remember Bugzilla_restrictlogin GoAheadAndLogIn ))
+      my $param (qw( Bugzilla_remember GoAheadAndLogIn ))
     {
       $uri->query_param_delete($param);
     }
@@ -101,7 +101,6 @@ sub login {
       user          => $user,
       type          => $type,
       reason        => 'Logging in as ' . $user->identity,
-      restrictlogin => $params->{Bugzilla_restrictlogin},
       remember      => $params->{Bugzilla_remember},
       url           => $uri->as_string,
       postback =>
@@ -119,8 +118,6 @@ sub mfa_verified {
 
   my $params = Bugzilla->input_params;
   $self->{_info_getter}->{successful} = Bugzilla::Auth::Login::CGI->new();
-  $params->{Bugzilla_restrictlogin} = $event->{restrictlogin}
-    if defined $event->{restrictlogin};
   $params->{Bugzilla_remember} = $event->{remember} if defined $event->{remember};
 
   $self->_handle_login_result({user => $user}, $event->{type});
index c71eb74fdc16f9088eb761a9db87097f53e38faf..46a47f4c5eaacf5befe9e5ac015ee78efe531817 100644 (file)
@@ -85,23 +85,16 @@ sub get_login_info {
     ($user_id, $login_cookie) = ($token->{'user_id'}, $token->{'login_token'});
   }
 
-  my $ip_addr = remote_ip();
-
   if ($login_cookie && $user_id) {
 
     # Anything goes for these params - they're just strings which
     # we're going to verify against the db
-    trick_taint($ip_addr);
     trick_taint($login_cookie);
     detaint_natural($user_id);
 
     my $db_cookie = $dbh->selectrow_array(
-      'SELECT cookie
-                                   FROM logincookies
-                                  WHERE cookie = ?
-                                        AND userid = ?
-                                        AND (restrict_ipaddr = 0 OR ipaddr = ?)',
-      undef, ($login_cookie, $user_id, $ip_addr)
+      'SELECT cookie FROM logincookies WHERE cookie = ? AND userid = ?',
+      undef, ($login_cookie, $user_id)
     );
 
     # If the cookie is valid, return a valid username.
index 65e6a15415d25ff3333a2771a2a9b2fc5579de5d..105c79ca2eeba5c6a1bf5275d24e2113777cb714 100644 (file)
@@ -39,13 +39,9 @@ sub persist_login {
 
   my $ip_addr = remote_ip();
   trick_taint($ip_addr);
-  my $restrict = $input_params->{Bugzilla_restrictlogin} ? 1 : 0;
 
-  $dbh->do(
-    "INSERT INTO logincookies (cookie, userid, ipaddr, lastused, restrict_ipaddr)
-              VALUES (?, ?, ?, NOW(), ?)", undef, $login_cookie, $user->id,
-    $ip_addr, $restrict
-  );
+  $dbh->do('INSERT INTO logincookies (cookie, userid, ipaddr, lastused)
+    VALUES (?, ?, ?, NOW())', undef, $login_cookie, $user->id, $ip_addr);
 
   # Issuing a new cookie is a good time to clean up the old
   # cookies.
index ee96220cf661b10ded3958a97e40d7b1c4454fdb..9356a1391b2ef48a007177d24c1bbc15f89a1378 100644 (file)
@@ -1138,7 +1138,6 @@ use constant ABSTRACT_SCHEMA => {
       ipaddr          => {TYPE => 'varchar(40)'},
       lastused        => {TYPE => 'DATETIME', NOTNULL => 1},
       id              => {TYPE => 'INTSERIAL', NOTNULL => 1, PRIMARYKEY => 1},
-      restrict_ipaddr => {TYPE => 'BOOLEAN', NOTNULL => 1, DEFAULT => 0},
     ],
     INDEXES => [
       logincookies_lastused_idx => ['lastused'],
index f9142fa4a124c1bac5a55b79b80cd327de3b6eb4..72a1cab6fc9365c8d4fe4a852b0f89ca0d48e9c7 100644 (file)
@@ -744,8 +744,6 @@ sub update_table_definitions {
 
   $dbh->bz_add_column('user_api_keys', 'last_used_ip', {TYPE => 'varchar(40)'});
 
-  _add_restrict_ipaddr();
-
   $dbh->bz_add_column('profiles', 'password_change_required',
     {TYPE => 'BOOLEAN', NOTNULL => 1, DEFAULT => 'FALSE'});
   $dbh->bz_add_column('profiles', 'password_change_reason',
@@ -782,6 +780,9 @@ sub update_table_definitions {
 
   _add_oauth2_jwt_support();
 
+  # Bug 1402894 - kohei.yoshino@gmail.com
+  $dbh->bz_drop_column('logincookies', 'restrict_ipaddr');
+
   ################################################################
   # New --TABLE-- changes should go *** A B O V E *** this point #
   ################################################################
@@ -4176,16 +4177,6 @@ sub _fix_disable_mail {
   Bugzilla->dbh->do("UPDATE profiles SET disable_mail = 1 WHERE is_enabled = 0");
 }
 
-sub _add_restrict_ipaddr {
-  my $dbh = Bugzilla->dbh;
-  return if $dbh->bz_column_info('logincookies', 'restrict_ipaddr');
-
-  $dbh->bz_add_column('logincookies', 'restrict_ipaddr',
-    {TYPE => 'BOOLEAN', NOTNULL => 1, DEFAULT => 0});
-  $dbh->do(
-    "UPDATE logincookies SET restrict_ipaddr = 1 WHERE ipaddr IS NOT NULL");
-}
-
 sub _migrate_group_owners {
   my $dbh = Bugzilla->dbh;
   return if $dbh->bz_column_info('groups', 'owner_user_id');
index 652a866c1c519d444d217519244c1e53ec65995a..6583d72f0afdef961d11814ba528c4a4f83334d3 100644 (file)
@@ -24,7 +24,6 @@ use constant DB_COLUMNS => qw(
   lastused
   ipaddr
   id
-  restrict_ipaddr
 );
 
 use constant UPDATE_COLUMNS => qw();
@@ -46,6 +45,5 @@ sub userid          { return $_[0]->{userid} }
 sub cookie          { return $_[0]->{cookie} }
 sub lastused        { return $_[0]->{lastused} }
 sub ipaddr          { return $_[0]->{ipaddr} }
-sub restrict_ipaddr { return $_[0]->{restrict_ipaddr} }
 
 1;
index 4a0264f9cefca6b900e0096e1bcc2a3ecbea94e2..82d27b99d13e22086a5945b1cb811fff6ffb052c 100644 (file)
@@ -193,19 +193,15 @@ WebService method to perform a login:
 
 =item C<Bugzilla_password> (string) - That user's password.
 
-=item C<Bugzilla_restrictlogin> (boolean) - Optional. If true,
-then your login will only be valid for your IP address.
-
 =item C<Bugzilla_rememberlogin> (boolean) - Optional. If true,
 then the cookie sent back to you with the method response will
 not expire.
 
 =back
 
-The C<Bugzilla_restrictlogin> and C<Bugzilla_rememberlogin> options
-are only used when you have also specified C<Bugzilla_login> and
-C<Bugzilla_password>. This value will be deprecated in the release
-after Bugzilla 5.0 and you will be required to pass the Bugzilla_login
+The C<Bugzilla_rememberlogin> option is only used when you have also specified
+C<Bugzilla_login> and C<Bugzilla_password>. This value will be deprecated in the
+release after Bugzilla 5.0 and you will be required to pass the Bugzilla_login
 and Bugzilla_password for every call.
 
 Note that Bugzilla will return HTTP cookies along with the method
index 3d078ad7a4bc66b3f848a221def99a002ee45044..6227e18257c4a4da90c22aee3e9ad552960dfda6 100644 (file)
@@ -111,13 +111,8 @@ name                    type     description
 ======================  =======  ==============================================
 **Bugzilla_login**      string   A user's login name.
 **Bugzilla_password**   string   That user's password.
-Bugzilla_restrictlogin  boolean  If true, then your login will only be
-                                 valid for your IP address.
 ======================  =======  ==============================================
 
-The ``Bugzilla_restrictlogin`` option is only used when you have also
-specified ``Bugzilla_login`` and ``Bugzilla_password``.
-
 There is also a deprecated method of authentication described below that will be
 removed in the version after Bugzilla 5.0.
 
index 1565425e5a0e1af29a6534d65405753be4a31796..6a01df0a1b6bfeb2b50f1d6b4d5b524d482c4f43 100644 (file)
@@ -28,9 +28,6 @@ name            type     description
 ==============  =======  ========================================================
 **login**       string   The user's login name.
 **password**    string   The user's password.
-restrict_login  boolean  If set to a true value, the token returned by this
-                         method will only be valid from the IP address which
-                         called this method.
 ==============  =======  ========================================================
 
 **Response**
index ffc9360213404691c58e43b159c873973b86d044..71ad9eab0e135f340867cb19a91faf3a2308fd66 100755 (executable)
@@ -73,7 +73,7 @@ else {
   # Only check the token if we are running this script from the
   # web browser and a parameter is passed to the script.
   # XXX - Maybe these two parameters should be deleted once logged in?
-  $cgi->delete('GoAheadAndLogIn', 'Bugzilla_restrictlogin', 'hooks_only');
+  $cgi->delete('GoAheadAndLogIn', 'hooks_only');
   if (scalar($cgi->param())) {
     my $token = $cgi->param('token');
     check_hash_token($token, ['sanitycheck']);
index 949a465492fdef2e65b9da0b77bf81f7386bff29..3737731dd9b98f2562e14fa15dcf3586bdd4e196 100644 (file)
@@ -1037,7 +1037,7 @@ input.required, select.required, span.required_explanation {
     font-weight: bold;
 }
 
-#login .field-restrict, #login .field-remember {
+#login .field-remember {
     margin-left: 7em;
 }
 
index f112c2a3b974d585f4f7ac8e10236280e06cce45..e777cabd84719ed439ee01f182cf825eb51dad8c 100644 (file)
@@ -25,7 +25,7 @@ only screen and (max-device-width : 720px) {
         padding-bottom: 0px;
     }
 
-    #login .field-restrict, #login .field-remember {
+    #login .field-remember {
         margin-left: 0px;
     }
     #login .field-submit {
index e1e59abe68b5ae9c15038b6587b42c5368d0882a..d91fe458b4ba7596270137931f6d4a40d92b73be 100644 (file)
@@ -67,7 +67,6 @@ $t->post_ok(
   '/login' => {Referer => $referer} => form => {
     Bugzilla_login         => $oauth_login,
     Bugzilla_password      => $oauth_password,
-    Bugzilla_restrictlogin => 1,
     GoAheadAndLogIn        => 1,
     client_id              => $oauth_client->{client_id},
     response_type          => 'code',
index f1e084ecbba3b94e26e94e8f0e0627be66c70e19..53ea9b283d895eb4b464b0f5e0cad763416b444c 100644 (file)
     [% END %]
 
     [% PROCESS "global/hidden-fields.html.tmpl"
-       exclude="^Bugzilla_(login|password|restrictlogin)$" %]
-
-    <div class="field-restrict">
-      <input type="checkbox" id="Bugzilla_restrictlogin" name="Bugzilla_restrictlogin"
-             checked="checked">
-      <label for="Bugzilla_restrictlogin" class="checkbox-note">
-        Restrict this session to this IP address
-        (using this option improves security)</label>
-    </div>
+       exclude="^Bugzilla_(login|password)$" %]
 
     <div class="field-submit">
       <input type="hidden" name="Bugzilla_login_token"
index 03d44287b82f296d99ae9a3688d3bca41575d939..9078ed3e8b8ca72e2d4b7015be1df30d00f9c623 100644 (file)
@@ -35,7 +35,6 @@
   <tr class="column_header">
     <th>Last used</th>
     <th>IP Address</th>
-    <th>IP Restriction</th>
     <th>Logout</th>
   </tr>
 
@@ -43,7 +42,6 @@
     <tr>
       <td>[% session.lastused FILTER time %]</td>
       <td>[% session.ipaddr OR "Unknown" FILTER html %]</td>
-      <td>[% session.restrict_ipaddr ? "Restricted" : "Unrestricted" FILTER html %]
       <td>
         [% IF session.current %]
           <b>(current)</b>
@@ -53,4 +51,4 @@
         [% END %]
     </tr>
   [% END %]
-</table>
\ No newline at end of file
+</table>