Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:71541 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 18350 invoked from network); 25 Jan 2014 01:40:35 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 25 Jan 2014 01:40:35 -0000 Authentication-Results: pb1.pair.com header.from=tyra3l@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=tyra3l@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.54 as permitted sender) X-PHP-List-Original-Sender: tyra3l@gmail.com X-Host-Fingerprint: 209.85.216.54 mail-qa0-f54.google.com Received: from [209.85.216.54] ([209.85.216.54:49221] helo=mail-qa0-f54.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 32/31-11879-F0613E25 for ; Fri, 24 Jan 2014 20:40:32 -0500 Received: by mail-qa0-f54.google.com with SMTP id i13so4742166qae.41 for ; Fri, 24 Jan 2014 17:40:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=R9gxXQWYiTDIP1rFehXRJvtzFR8/MBZ83ofzmNvK6xA=; b=KZTxNunwZmkbFfDitejEOMRymN73UkEmxfZobLv6i0E8qH6GmakD4wVk75dOso47F7 xak210UthUT4OLgkIKVDB3xA8UJl/GAhB0FLFDXY2CAD5qVbM9hsXeHmim7MuSmchgMQ lB3gdy43Ppqlrvt6GCF1RePwi8J8YOdrwbqd25hqJ4ZcPHeyGbD+x2sSyGCqQZgjnQCd 8Bc+HmA18eeDm9tJv6FpTrqKBQDskARC/lW1L7Ft32tnaFL25o3bp1ir+OzBzKcnfuY5 AkuI7oRc9HFZEKal61EEHc7sIWOBep2Iae5YzCYGShIUH1O1PkxdZeylXT4MxDDhYYKz 1ZkQ== MIME-Version: 1.0 X-Received: by 10.140.40.5 with SMTP id w5mr23899254qgw.65.1390614028630; Fri, 24 Jan 2014 17:40:28 -0800 (PST) Received: by 10.140.96.70 with HTTP; Fri, 24 Jan 2014 17:40:28 -0800 (PST) In-Reply-To: References: Date: Sat, 25 Jan 2014 02:40:28 +0100 Message-ID: To: Andrey Andreev Cc: "internals@lists.php.net" Content-Type: multipart/alternative; boundary=001a11c12976323fb504f0c18ff1 Subject: Re: [PHP-DEV] Session IP address matching From: tyra3l@gmail.com (Ferenc Kovacs) --001a11c12976323fb504f0c18ff1 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Sat, Jan 25, 2014 at 2:11 AM, Andrey Andreev wrote: > Hello, > > ext/session lacks the option to check the visitor's IP address and this i= s > a much needed feature for pretty much everybody writing web applications > today. I'll call it 'session.match_ip' for now. > So much needed in fact, that I'm surprised PHP made it to 2014 without th= at > option, especially since there already is 'session.referer_check'. > > Yes, one can write a custom session handler, but there's a number of > problems with that: > > - Most people don't know enough to do it properly, more specifically - h= ow > to handle concurrency. > > - The documentation available is pretty limited. > > - Unless I want another type of storage, why should I bother trying to > replicate ext/session just for this one option? > > And of course, there are a few pre-made handlers in PECL, but those are > afaik no longer maintaned and not feasible if you'd be distributing your > end product instead of just running it yourself. > > I'd write an RFC about it, but I know it doesn't stand a good chance > without a patch to go with it and I'm not comfortable enough with my C > knowledge to do it myself. It should be simple enough in theory though ..= . > > - Create an MD5 hash of REMOTE_ADDR and do one of these: > > - Prepend it to the session file name > - Create a directory named after it under session.save_path > - Have the option to specify it in session.save_path itself, like it'= s > done with N and MODE > > It shouldn't cause any BC breaks and the only issue I can think of is los= s > of existing sessions when the option is being turned On/Off. I wouldn't b= e > bothered by that really, it should be expected. > > So, how do you guys feel about this? Would anybody be willing to write th= e > patch (I'll do the RFC)? > > Cheers, > Andrey Andreev a.k.a. Narf. > For the record suhosin supports this( http://www.hardened-php.net/suhosin/configuration.html#suhosin.session.cryp= traddr) but to quote from the docs: "Keep in mind that this should not be used on sites that have visitors from big ISPs, because their IP address often changes during a session. But this feature might be interesting for admin interfaces or intranets." I agree with that statement, and this is why this can't be a default behavior, and given how easy is to extend the default SessionHandler, I'm not even sure about providing an optional implementation for this. --=20 Ferenc Kov=C3=A1cs @Tyr43l - http://tyrael.hu --001a11c12976323fb504f0c18ff1--