Changeset 5121 in subversion


Ignore:
Timestamp:
Aug 24, 2011 9:15:40 AM (21 months ago)
Author:
thomasb
Message:

Allow to configure an URL to redirect the client after logout (#1487953)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/plugins/http_authentication/http_authentication.php

    r5094 r5121  
    66 * Make use of an existing HTTP authentication and perform login with the existing user credentials 
    77 * 
    8  * @version 1.3 
     8 * Configuration: 
     9 * // redirect the client to this URL after logout. This page is then responsible to clear HTTP auth 
     10 * $rcmail_config['logout_url'] = 'http://server.tld/logout.html'; 
     11 * 
     12 * see http://stackoverflow.com/questions/31326/is-there-a-browser-equivalent-to-ies-clearauthenticationcache 
     13 * about how HTTP auth can be cleared 
     14 * 
     15 * @version 1.4 
    916 * @author Thomas Bruederli 
    1017 */ 
    1118class http_authentication extends rcube_plugin 
    1219{ 
    13   public $task = 'login'; 
     20  public $task = 'login|logout'; 
    1421 
    1522  function init() 
     
    1724    $this->add_hook('startup', array($this, 'startup')); 
    1825    $this->add_hook('authenticate', array($this, 'authenticate')); 
     26    $this->add_hook('logout_after', array($this, 'logout')); 
    1927  } 
    2028 
     
    4755    return $args; 
    4856  } 
     57   
     58  function logout($args) 
     59  { 
     60    // redirect to configured URL in order to clear HTTP auth credentials 
     61    if (!empty($_SERVER['PHP_AUTH_USER']) && $args['user'] == $_SERVER['PHP_AUTH_USER'] && ($url = rcmail::get_instance()->config->get('logout_url'))) { 
     62      header("Location: $url", true, 307); 
     63    } 
     64  } 
    4965 
    5066} 
Note: See TracChangeset for help on using the changeset viewer.