Author Topic: Automaticaly Login  (Read 9664 times)

Offline prisma

  • Newbie
  • *
  • Posts: 8
Automaticaly Login
« on: July 19, 2010, 08:48:33 AM »
We have our own Webbased CRM System. If somebody is logged into our system, I don't want him to be forced to re-enter his email-credentials to log into RC.

So I tried to post the relevant values to RC:


   





User:

Password:

       


 

But it doesn't work, I'm not automatically logged in. Seems to be cookie and/or session related. Has anybody an idea how to get this work? Is there a possibillity to turn off the necessity of an initial cookie before login? Or has anybody another idea to realize my "single-sign-on" scenario?

Offline rosali

  • Hero Member
  • *****
  • Posts: 2,533
Automaticaly Login
« Reply #1 on: July 19, 2010, 08:55:18 AM »
myroundcube - Project Hosting on Google Code

Check plugin 'logout_redirect'. See example in ajax_login folder.
Regards,
Rosali
__________________
MyRoundcube Project (commercial)

Offline prisma

  • Newbie
  • *
  • Posts: 8
Already seen
« Reply #2 on: July 19, 2010, 11:37:53 AM »
I have already seen this code, but the problem with this seems to be the missing cookie also. If you click the link of this sniplet the first time, it doesn't work, you get "wrong user or pass". If you click the link the second time without changing the credentials, login is successful.

This is not helpful, or did I anything wrong? any other ideas? At the moment I'm trying the plugin "autologin" but couldn't get it work also. Has anybody any experiences with this plugin?

Offline rosali

  • Hero Member
  • *****
  • Posts: 2,533
Automaticaly Login
« Reply #3 on: July 19, 2010, 12:42:28 PM »
It works for me on first time login. Hmmm? Did you change the action url in the form correctly?
Regards,
Rosali
__________________
MyRoundcube Project (commercial)

Offline SKaero

  • Administrator
  • Hero Member
  • *****
  • Posts: 5,879
    • SKaero - Custom Roundcube development
Automaticaly Login
« Reply #4 on: July 19, 2010, 02:10:42 PM »
If your using the autologin example plugin /trunk/plugins/autologon/autologon.php ? Roundcube Webmail Keep in mind that it only allows you to login if you are accessing RoundCube form localhost, you would need to take out the checks to $this->is_localhost() for it to automatically login otherwise.

Offline prisma

  • Newbie
  • *
  • Posts: 8
here is what I have:
« Reply #5 on: July 20, 2010, 03:55:16 AM »
$rcmail_config['plugins'] = array('autologon');
<?php

class autologon 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();

    
// change action to login
    
if ($args['task'] == 'mail' && empty($args['action']) && empty($_SESSION['user_id']) && !empty($_GET['_autologin']))
      
$args['action'] = 'login';

    return 
$args;
  }

  function 
authenticate($args)
  {
    if (!empty(
$_GET['_autologin'])) {
      
$args['user'] = 'xxx';
      
$args['pass'] = 'yyy';
      
$args['host'] = 'ssl://dummy.dyndns.org:30993';
    }
  
    return 
$args;
  }

 }

Webmail called with:
<?php
echo '
<form name="roundcubelogin" action="https://mydomain.org(!!yes, I know)/webmail/?_task=mail" method="post" target="roundcube">
<input type="hidden" name="_timezone" value="2" />
<input type="hidden" name="_task" value="mail" />
<input type="hidden" name="_autologin" value="1" />
<input type="hidden" name="_host" value="ssl://dummy.dyndns.org:30993" />
<input type="hidden" name="_user" value="xxx" />
<input type="hidden" name="_pass" value="yyy" />
</form>
<a href="#" onclick="document.forms.roundcubelogin.submit()">Webmail</a>
'
;
?>

If I understood the plugin right it shouldn't be necessary to have _host,_user, _pass in the calling script (last above). But I let it in, for sure.

If it is THAT easy to enable autologon, you'd only have to copy an paste the code above to your enviroment, add the credentials and urls and everything should work. Would you please be so kind to test this? Or what do you both use? Could you post it?

Offline SKaero

  • Administrator
  • Hero Member
  • *****
  • Posts: 5,879
    • SKaero - Custom Roundcube development
Automaticaly Login
« Reply #6 on: July 20, 2010, 04:12:21 AM »
I see a couple of problems with your code, first in the auto login plugin your making calls to $_GET['_autologin'] however your form is post not get so the auto login will never start. Second your form, I haven't tried this but I think you should be sending it to:
Code: [Select]
?_task=login not:
Code: [Select]
?_task=mail

Offline prisma

  • Newbie
  • *
  • Posts: 8
Thank you!!!
« Reply #7 on: July 20, 2010, 06:13:55 AM »
Youre hint with GET was the key, I changed autologon.php from _GET to _POST and it worked NEARLY. But the cookie problem still existed. For this I found a sniplet from a guy, who modified the autologon plugin to something called autologIN himself. he added to funktion startup:

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


I think, whatever method will be used, post or get, everybody who uses the autologon.php could have the cookie problem. This plugin is part of a stable release. So you guys should think about to add this line to the next stable release. For better understanding, here is, what I got now working:

login.php:<?php
echo '

<form name="roundcubelogin" action="https://mydomain.com/webmail/?_task=mail" method="post" target="roundcube">
<input type="hidden" name="_autologin" value="1" />
<input type="hidden" name="_user" value="xxx" />
<input type="hidden" name="_pass" value="yyy" />
</form>
<a href="#" onclick="document.forms.roundcubelogin.submit()">Webmail</a>

'
;
?>

autologon.php<?php

class autologon 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();

    
// change action to login
    
if ($args['task'] == 'mail' && empty($args['action']) && empty($_SESSION['user_id']) && !empty($_POST['_autologin']))
      
$args['action'] = 'login';

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

    return 
$args;
  }

  function 
authenticate($args)
  {
    if (!empty(
$_POST['_autologin'])) {
      
$args['user'] = $_POST['_user'];
      
$args['pass'] = $_POST['_pass'];
      if (!empty(
$_POST['_host']))
        
$args['host'] = $_POST['_host'];
    }
  
    return 
$args;
  }

 }

Offline SKaero

  • Administrator
  • Hero Member
  • *****
  • Posts: 5,879
    • SKaero - Custom Roundcube development
Automaticaly Login
« Reply #8 on: July 20, 2010, 06:30:25 AM »
It works fine for me with out that line, I am guessing that it a configuration problem of some sort.

Offline prisma

  • Newbie
  • *
  • Posts: 8
I configured nothing
« Reply #9 on: July 20, 2010, 06:43:46 AM »
I configured nothing, except the things the installer asked me. I don't know if you're developing, but as developer I'd try this with a clean installation. AND have you tried to clear up your cookie cache before login? I'm quite sure you'll have the same problem then. If not, please let me know.

Offline SKaero

  • Administrator
  • Hero Member
  • *****
  • Posts: 5,879
    • SKaero - Custom Roundcube development
Automaticaly Login
« Reply #10 on: July 20, 2010, 01:33:15 PM »
Works for me with a clean install of 0.4beta and the SVN, I think that its a server or browser configuration problem and directly with RoundCube.

Offline peachmelba

  • Newbie
  • *
  • Posts: 7
    • http://sidsteojeblik.dk
step by step please
« Reply #11 on: October 18, 2010, 10:28:28 AM »
Hi All.

Can someone please explain to me step by step what to do?

I am not a PHP coder guy so please help a noob like me:D

I have roundcube installed on my joomla installation, and i am only using one email address. When i enter my page i want to go directly to my mails without have to type in my username, password and servername.

Thx in advice.

Offline SKaero

  • Administrator
  • Hero Member
  • *****
  • Posts: 5,879
    • SKaero - Custom Roundcube development
Automaticaly Login
« Reply #12 on: October 19, 2010, 05:37:28 AM »
You would need to do something different for it to work with Joomla, I have a RoundCube-Joomla integration plugin, contact if you want more details.

Offline Maeggi07

  • Newbie
  • *
  • Posts: 1
Automaticaly Login
« Reply #13 on: February 03, 2011, 02:27:21 PM »
Hello i´m new here.
I am from Germany, sry for my English.
I am interested to your Plugin for Joomla.

You have Post
"I have a RoundCube-Joomla integration plugin, contact if you want more details. "

Is the Plugin free available?
That would be really great.

Thank

Best Regards

Maeggi

Offline SKaero

  • Administrator
  • Hero Member
  • *****
  • Posts: 5,879
    • SKaero - Custom Roundcube development
Automaticaly Login
« Reply #14 on: February 03, 2011, 04:23:44 PM »
Unfortunately its not freely available at this time, I'm not looking to make a profit I'm just trying to cover some of time I spent coding it. Contact me if your interested.