FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » FUDforum Development » Plugins and Code Hacks » Proposed code change to add AUTO_LOGIN plugin hook
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
Proposed code change to add AUTO_LOGIN plugin hook [message #184653] Tue, 14 January 2014 16:26 Go to next message
kmoradha is currently offline  kmoradha
Messages: 8
Registered: January 2014
Karma: 0
Junior Member
This code change adds a new plugin hook named "AUTO_LOGIN" to allow automatic user login based on external authentication methods. We are currently using this in combination with a Basic Authentication configuration on the web server.

The plugin hook is only used if a saved session is not initially identifiable, and before an anonymous session is created.

Please review the code change below:

--- users.inc.t-orig    2014-01-14 11:08:47.608988091 -0500
+++ users.inc.t 2014-01-14 11:13:50.702268354 -0500
@@ -655,6 +655,11 @@
        $sq = 0;
        /* Fetch an object with the user's session, profile & theme info. */
        if (!($u = ses_get())) {
+               /* Call auto-login plugins. */
+               $u = plugin_call_hook('AUTO_LOGIN');
+       }
+
+       if (!$u) {
                /* New anon user. */
                $u = ses_anon_make();
        } else if ($u->id != 1 && (!$GLOBALS['is_post'] || sq_check(1, $u->sq, $u->id, $u->ses_id))) {
Re: Proposed code change to add AUTO_LOGIN plugin hook [message #184654 is a reply to message #184653] Tue, 14 January 2014 17:23 Go to previous messageGo to next message
naudefj is currently offline  naudefj   
Messages: 3771
Registered: December 2004
Karma: 28
Senior Member
Administrator
Core Developer
Would it be possible to maybe use the AUTHENTICATE hook for this?

Quote:
Authenticate users against an external source like an LDAP directory. Example implementation: Email_login.plugin and Ldap.plugin.
Re: Proposed code change to add AUTO_LOGIN plugin hook [message #184655 is a reply to message #184654] Tue, 14 January 2014 17:31 Go to previous messageGo to next message
kmoradha is currently offline  kmoradha
Messages: 8
Registered: January 2014
Karma: 0
Junior Member
No, the AUTHENTICATE hook occurs after the user has submitted login credentials into the login form. The purpose of this hook is to prevent the need for the login form altogether, to be used when user authentication can be done using some external factor (such as Basic auth that might be configured with a single sign-on solution).
Re: Proposed code change to add AUTO_LOGIN plugin hook [message #184656 is a reply to message #184654] Tue, 14 January 2014 17:39 Go to previous messageGo to next message
naudefj is currently offline  naudefj   
Messages: 3771
Registered: December 2004
Karma: 28
Senior Member
Administrator
Core Developer
OK, maybe not. AUTHENTICATE is in 'login.php.t' and you want to authenticate users without going through the login dialogue.

Maybe just add the following so clutch out all plugins and commit:
if (defined('plugins')) {

Re: Proposed code change to add AUTO_LOGIN plugin hook [message #184657 is a reply to message #184656] Tue, 14 January 2014 17:43 Go to previous messageGo to next message
kmoradha is currently offline  kmoradha
Messages: 8
Registered: January 2014
Karma: 0
Junior Member
Just to be sure, here's how I interpret that:

--- users.inc.t-orig    2014-01-14 11:08:47.608988091 -0500
+++ users.inc.t 2014-01-14 12:42:28.902660593 -0500
@@ -654,7 +654,12 @@

        $sq = 0;
        /* Fetch an object with the user's session, profile & theme info. */
-       if (!($u = ses_get())) {
+       if (!($u = ses_get()) && defined('plugins')) {
+               /* Call auto-login plugins. */
+               $u = plugin_call_hook('AUTO_LOGIN');
+       }
+
+       if (!$u) {
                /* New anon user. */
                $u = ses_anon_make();
        } else if ($u->id != 1 && (!$GLOBALS['is_post'] || sq_check(1, $u->sq, $u->id, $u->ses_id))) {
Re: Proposed code change to add AUTO_LOGIN plugin hook [message #184661 is a reply to message #184657] Tue, 14 January 2014 18:07 Go to previous messageGo to next message
naudefj is currently offline  naudefj   
Messages: 3771
Registered: December 2004
Karma: 28
Senior Member
Administrator
Core Developer
I cannot test right now, but it looks about right. If it works, go for it!

Please also update FUDforum 3.0.6 and Plugins (Available hooks).
Re: Proposed code change to add AUTO_LOGIN plugin hook [message #184662 is a reply to message #184661] Tue, 14 January 2014 18:22 Go to previous message
kmoradha is currently offline  kmoradha
Messages: 8
Registered: January 2014
Karma: 0
Junior Member
Committed (rev 5758) and documented. Thanks!
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Proposed code change for potentially more unique sysid
Next Topic: How to use Search plugin hook
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Tue Dec 03 18:59:58 GMT 2024

Total time taken to generate the page: 0.02442 seconds