Forums / Developer / Authenticating by IP?

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

eZ debug

Timing: Jan 19 2025 03:30:59
Script start
Timing: Jan 19 2025 03:30:59
Module start 'content'
Timing: Jan 19 2025 03:31:01
Module end 'content'
Timing: Jan 19 2025 03:31:01
Script end

Main resources:

Total runtime2.1556 sec
Peak memory usage4,096.0000 KB
Database Queries191

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0093 588.8516180.8438
Module start 'content' 0.00931.9504 769.6953528.3516
Module end 'content' 1.95970.1958 1,298.0469332.7578
Script end 2.1555  1,630.8047 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00590.2735210.0003
Check MTime0.00180.0852210.0001
Mysql Total
Database connection0.00100.044510.0010
Mysqli_queries2.053895.27881910.0108
Looping result0.00240.11271890.0000
Template Total2.110197.921.0551
Template load0.00400.185520.0020
Template processing2.106197.702921.0530
Template load and register function0.00060.026310.0006
states
state_id_array0.00250.115810.0025
state_identifier_array0.00150.070720.0008
Override
Cache load0.00280.130290.0003
Sytem overhead
Fetch class attribute can translate value0.00150.070630.0005
Fetch class attribute name0.00120.053430.0004
XML
Image XML parsing0.00130.062530.0004
class_abstraction
Instantiating content class attribute0.00000.000430.0000
General
dbfile0.00990.4583270.0004
String conversion0.00000.000530.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

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
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/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