Authenticating by IP?

Author Message

Petter Arneson

Thursday 29 December 2005 1:19:27 am

Im currently working on a project, using 3.7.2, where we have to include an iframe from another server. They want to use user id, session id and ip to authenticate the user. I send this information to the iframe, and they send it back for authentication. E.g. a script that returns true or false. I can send the users ip since this is done by a templateoperator for current user. But how can I get this users ip in the auth script? I can get the correct user, but as far as I can see ez doesn't save ip in session or user object information. I probably could alter the session table, to include ip, but I dont want to mess to much with the kernel. Does anyone know exactly where this could be done? I think session id is enough to authenticate the correct user, but how do I convice them of this?

www.vzt.no

Kristian Hole

Friday 30 December 2005 4:15:43 am

Hi

This is a patch for 3.5.1 which allows one specific user to log in from one specific IP. You can probably get some idea about how to do something like you want from this.

--- pre_check.php.orig  2005-04-06 15:24:51.020472000 +0200
+++ pre_check.php       2005-04-06 16:10:16.603120456 +0200
@@ -84,6 +84,21 @@
     $requireUserLogin = ( $ini->variable( "SiteAccessSettings", "RequireUserLogin" ) == "true" );
     $check = null;
     $http =& eZHTTPTool::instance();
+
+       //---LOGINONIP-HACK
+    if ( $ini->hasVariable( 'LoginOnIP', 'IPAddress' ) && $ini->hasVariable( 'LoginOnIP', 'UserID' )
+         && $_SERVER['REMOTE_ADDR'] == trim( $ini->variable( 'LoginOnIP', 'IPAddress' ) ) )
+    {
+        include_once( 'kernel/classes/datatypes/ezuser/ezuser.php' );
+        $userID = ( int ) $ini->variable( 'LoginOnIP', 'UserID' );
+        $user = eZUser::fetch( $userID );
+        if ( ! is_object( $user ) )
+            eZDebug::writeDebug( "Unable to fetch user with id $userID for IP login", "LoginOnIP" );
+        else
+            eZUser::setCurrentlyLoggedInUser( $user, $userID );
+    }
+       //---/LOGINONIP-HACK
+
     if ( !$requireUserLogin )
         return null;
 //     $uri =& $GLOBALS['eZRequestedURI'];

Kristian

http://ez.no/ez_publish/documenta...tricks/show_which_templates_are_used
http://ez.no/doc/ez_publish/techn...te_operators/miscellaneous/attribute

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 19:23:03
Script start
Timing: Jan 18 2025 19:23:03
Module start 'layout'
Timing: Jan 18 2025 19:23:03
Module start 'content'
Timing: Jan 18 2025 19:23:04
Module end 'content'
Timing: Jan 18 2025 19:23:04
Script end

Main resources:

Total runtime0.6925 sec
Peak memory usage4,096.0000 KB
Database Queries54

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0077 588.9297152.6094
Module start 'layout' 0.00770.0032 741.539139.4141
Module start 'content' 0.01100.6799 780.9531523.2891
Module end 'content' 0.69090.0016 1,304.242212.1875
Script end 0.6925  1,316.4297 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00320.4549160.0002
Check MTime0.00140.1955160.0001
Mysql Total
Database connection0.00240.352110.0024
Mysqli_queries0.646493.3427540.0120
Looping result0.00050.0788520.0000
Template Total0.661495.520.3307
Template load0.00230.335920.0012
Template processing0.659195.170120.3295
Template load and register function0.00020.024010.0002
states
state_id_array0.00120.167210.0012
state_identifier_array0.00080.120720.0004
Override
Cache load0.00190.275890.0002
Sytem overhead
Fetch class attribute can translate value0.00070.096820.0003
Fetch class attribute name0.00150.212530.0005
XML
Image XML parsing0.00100.149220.0005
class_abstraction
Instantiating content class attribute0.00000.003730.0000
General
dbfile0.00070.1050160.0000
String conversion0.00000.001440.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
2content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
2content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 8
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs