Author Topic: RC plugin autologin from CMS or Portal ...  (Read 25586 times)

Offline talvins

  • Jr. Member
  • **
  • Posts: 26
RC plugin autologin from CMS or Portal ...
« Reply #15 on: February 27, 2011, 02:19:03 PM »
Doesn't work for me: "Invalid request! No data was saved."

Using :
     
     
     
      ">
      ">
     

with $mailpass = strrev(base64_encode('my_key'.$good_password)

Offline rosali

  • Hero Member
  • *****
  • Posts: 2,533
RC plugin autologin from CMS or Portal ...
« Reply #16 on: February 27, 2011, 11:29:06 PM »
It does not work since v0.5.1 due to CSFR protection of the login request.

Check my logout_redirect plugin and adust the outside login form as shown in the folder ajax_login.
Regards,
Rosali
__________________
MyRoundcube Project (commercial)

Offline talvins

  • Jr. Member
  • **
  • Posts: 26
RC plugin autologin from CMS or Portal ...
« Reply #17 on: March 04, 2011, 09:38:22 AM »
Doesn't work : authentication failed. I tried directly with your entire plugin, using ajax_login.php as login interface.

Could you explain what has changed in the authentication process? hash/hash+salt and same in DB ? symetric encryption ?

Thanks.

Offline rosali

  • Hero Member
  • *****
  • Posts: 2,533
RC plugin autologin from CMS or Portal ...
« Reply #18 on: March 04, 2011, 10:59:53 AM »
There is a small bug in the plugin, which will be fixed in next release.

It should work if you adjust the action url in ajax_login.php and if
the referer url in the config file is properly defined.

The change was that login needs a Roundcube generated token in
the login form. If you login from outside, you can't have the token.
The token is stored in the (Roundcube) session. The workaround is
to have a plugin which sets the return argument 'valid' to true
on authenticate hook. If you have a little bit PHP skills, just look
into the authenticate hook of the plugin and you'll see what to do.
Regards,
Rosali
__________________
MyRoundcube Project (commercial)

Offline talvins

  • Jr. Member
  • **
  • Posts: 26
RC plugin autologin from CMS or Portal ...
« Reply #19 on: March 04, 2011, 11:44:32 AM »
In fact, after tracing, I have a problem with your authenticate function.

$args['valid'] is true only if
        $rcmail->config->get('logout_redirect_referer', false) &&
        stristr($_SERVER['HTTP_REFERER'],$rcmail->config->get('logout_redirect_referer'))

But it's false in my conf, so $args['valid'] is never true.

Offline talvins

  • Jr. Member
  • **
  • Posts: 26
RC plugin autologin from CMS or Portal ...
« Reply #20 on: March 04, 2011, 12:24:06 PM »
Why your fonction doesn't work with GET datas ? Even if I change _POST with _REQUEST.

Offline rosali

  • Hero Member
  • *****
  • Posts: 2,533
RC plugin autologin from CMS or Portal ...
« Reply #21 on: March 04, 2011, 01:34:07 PM »
Make your own plugin for your needs. Just use the authenticate hook ...

It is quite easy:
Code: [Select]

class external_login extends rcube_plugin
{
  public $task = 'login|logout';
 
  function init()
  {
    $this->add_hook('authenticate', array($this, 'authenticate'));
  }

  function authenticate($args)
  {
    // validate request if desired and however you want to do it
    // if validation is passed, then return true ...
    $args['valid'] = true;
    return $args;
  }
}
Regards,
Rosali
__________________
MyRoundcube Project (commercial)

Offline talvins

  • Jr. Member
  • **
  • Posts: 26
RC plugin autologin from CMS or Portal ...
« Reply #22 on: March 05, 2011, 12:26:49 PM »
Ok, I'll look for that.

thanks a lot.

Offline dorsig

  • Newbie
  • *
  • Posts: 1
RC plugin autologin from CMS or Portal ...
« Reply #23 on: August 26, 2011, 05:39:55 AM »
change the class like this should work:

class autologin extends rcube_plugin
{

  function 
init()
  {
    
$this->add_hook('startup', array($this'startup'));
    
$this->add_hook('authenticate', array($this'authenticate'));
  }

  function 
startup($args)
  {
    
$rcmail rcmail::get_instance();

    
$autologin get_input_value('_autologin'RCUBE_INPUT_POST);
    
// change action to login
    
if ($args['task'] == 'login' && empty($args['action']) && empty($_SESSION['user_id']) && !empty($autologin)) {
      
$args['action'] = 'login';

      
// decode pass, revert and replace key
           
$_POST['_pass'] = str_replace('*yourpass*','',base64_decode(strrev(get_input_value('_pass'RCUBE_INPUT_POSTtrue'ISO-8859-1'))));

      
// set initial cookie without this cookie login is not possible
      
$_COOKIE['roundcube_sessid'] = session_id();
    }
    return 
$args;
  }

  function 
authenticate($args)
  {
    
$autologin get_input_value('_autologin'RCUBE_INPUT_POST);

    if (!empty(
$autologin)) {
      
$args['user'] = get_input_value('_user'RCUBE_INPUT_POST);
      
$args['pass'] = get_input_value('_pass'RCUBE_INPUT_POST);
      
$args['host'] = get_input_value('_host'RCUBE_INPUT_POST);
      
$args['cookiecheck'] = false;
      
$args['valid'] = true;
    }
    return 
$args;
  }
}

Offline belyitigr@gmail.com

  • Newbie
  • *
  • Posts: 1
problems with autologin
« Reply #24 on: September 08, 2011, 01:39:26 PM »
Hi!

I have roundmail-0.6Rc and try use this script for autologin. But alwasys have errror...'Your session is invalid or expired.'
Maybe somebody know how resolve this? My param..

$_SESSION['userpassword'] = strrev(base64_encode('3108'.'111'));

echo '






Submit
';


and class code

class autologin extends rcube_plugin
{
  function init()
  {
    $this->add_hook('startup', array($this, 'startup'));
    $this->add_hook('authenticate', array($this, 'authenticate'));
  }

  function startup($args)
  {
    $rcmail = rcmail::get_instance();

    $autologin = get_input_value('_autologin', RCUBE_INPUT_POST);
    // change action to login
    if ($args['task'] == 'login' && empty($args['action']) && empty($_SESSION['user_id']) && !empty($autologin)) {
      $args['action'] = 'login';

      // decode pass, revert and replace key
           $_POST['_pass'] = str_replace('3108','',base64_decode(strrev(get_input_value('_pass', RCUBE_INPUT_POST, true, 'ISO-8859-1'))));

      // set initial cookie without this cookie login is not possible
      $_COOKIE['roundcube_sessid'] = session_id();
    }
    return $args;
  }

  function authenticate($args)
  {
    $autologin = get_input_value('_autologin', RCUBE_INPUT_POST);

    if (!empty($autologin)) {
      $args['user'] = get_input_value('_user', RCUBE_INPUT_POST);
      $args['pass'] = get_input_value('_pass', RCUBE_INPUT_POST);
      $args['host'] = get_input_value('_host', RCUBE_INPUT_POST);
      $args['cookiecheck'] = false;
      $args['valid'] = true;
    }
    return $args;
  }
}

Offline andrusha777

  • Newbie
  • *
  • Posts: 1
RC plugin autologin from CMS or Portal ...
« Reply #25 on: September 14, 2011, 07:43:57 AM »
Hi! The code change in plugin from dorsig posted above has fixed autologin plugin. It was working for me along time, but after updated to 0.5.4 from 0.5 beta - autologin was broken. Changing the code has fixed this problem. Don't know about 0.6 and above...

createafreeblog

  • Guest
create a blog" if possible
« Reply #26 on: September 15, 2011, 01:33:31 AM »
Create a free blog


Create Free Blog | Free Blog WP WordPress


Use this website

Offline apeitup

  • Newbie
  • *
  • Posts: 3
RC plugin autologin from CMS or Portal ...
« Reply #27 on: September 23, 2011, 12:56:49 PM »
Does this plugin work on v0.54. Only I desperately need to get this running.

Offline tlq123

  • Newbie
  • *
  • Posts: 2
    • http://www.waterionizer.com.cn
RC plugin autologin from CMS or Portal ...
« Reply #28 on: September 26, 2011, 02:52:27 AM »
Thanks for the information,just found this post my technorati news feed section! I was searching for this since past 3 months and i am glad to see it here. Thanking you much