<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Rommel Santor&#039;s Clog &#187; suhosin session mediawiki</title>
	<atom:link href="https://rommelsantor.com/clog/tag/suhosin-session-mediawiki/feed/" rel="self" type="application/rss+xml" />
	<link>https://rommelsantor.com/clog</link>
	<description>my exploits and misadventures in programming</description>
	<lastBuildDate>Thu, 04 Feb 2016 12:56:01 +0000</lastBuildDate>
	<language>en-US</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.0.38</generator>
	<item>
		<title>PHP Shared Session Encoding Solution</title>
		<link>https://rommelsantor.com/clog/2011/02/06/php-shared-session-encoding-solution/</link>
		<comments>https://rommelsantor.com/clog/2011/02/06/php-shared-session-encoding-solution/#comments</comments>
		<pubDate>Sun, 06 Feb 2011 20:24:40 +0000</pubDate>
		<dc:creator><![CDATA[rommel]]></dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[suhosin session mediawiki]]></category>

		<guid isPermaLink="false">http://rommelsantor.com/clog/?p=140</guid>
		<description><![CDATA[I came up against a really baffling problem the other day. I was tasked with adding a Wiki for VideoSift. Rather than just dumping MediaWiki onto the primary VideoSift web server, we wanted to keep it self-contained for security and load reasons, so we installed into one of our other back-end servers which was being [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>I came up against a really baffling problem the other day. I was tasked with adding a <a href="http://wiki.videosift.com">Wiki for VideoSift</a>. Rather than just dumping MediaWiki onto the primary VideoSift web server, we wanted to keep it self-contained for security and load reasons, so we installed into one of our other back-end servers which was being used as a MySQL Slave and not hosting any web content. To start with I just did a quick, basic install of Apache2 and PHP5 (I would prefer and attempted to use Nginx with PHP5-FPM, but MediaWiki complains about implementation bugs in the packaged versions available to me and I don&#8217;t want to recompile from source).</p>
<p><span id="more-140"></span>
<div style="float:left;margin:0 10px 10px 0">
<script type="text/javascript"><!--
google_ad_client = "ca-pub-7639656561235411";
/* Square (250x250) */
google_ad_slot = "8522038794";
google_ad_width = 250;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>
</p>
<p>I have never dealt with MediaWiki previously, so I just went and setup the wiki.videosift.com subdomain to load from the back-end server then downloaded the tarball into the document root and went through the install process. I spent an inordinate amount of time figuring out how it might be possible to synchronize existing VideoSift member accounts and logins seamlessly into the Wiki, (but the details of how I did that are for another story, which I may clog about soon). All of my software changes seemed to make sense and even after in-depth inspection should have been functioning properly, but if anyone went from VideoSift to the Wiki or vice versa, they were instantly automatically being logged out of both.</p>
<p>After spending many clueless hours debugging back and forth, I finally found that the <a href="http://www.php.net/manual/en/book.session.php" target="_blank">sessions</a> designed to be properly shared across the two servers was to blame. The session data on one server would be written to a centralized session depot and the other server should have read that session data, allowing the session to persist across both websites.</p>
<p>I use <a href="http://www.php.net/manual/en/function.session-set-save-handler.php" target="_blank">session_set_save_handler()</a> to manipulate how sessions are managed, so I put in some debug code on both servers to dump the raw session data that was being read and written. To my surprise they were totally different. On the Wiki the session data was a normal session-serialized string of variable data like this:<br />
<tt>&nbsp;&nbsp;test|s:3:"sdf";</tt><br />
but the VideoSift session contained a seemingly random string of characters:<br />
<tt>&nbsp;&nbsp;3GdlPEGr2kYgRFDs-pUSoKomZ4fN7r5BM5oKOCMsWNc</tt></p>
<p>After a lot more digging and googling, I finally came across <a href="http://www.php.net/manual/en/function.session-set-save-handler.php#89564" target="_blank">this comment at php.net</a>. Unbeknownst  to me, as a security measure, the <a href="http://www.hardened-php.net/suhosin/index.html" target="_blank">suhosin module</a> for PHP was using its <a href="http://www.hardened-php.net/suhosin/configuration.html#transparent_encryption_options" target="_blank">Transparent Encryption Options</a> to automatically encrypt all session data as it was being written.</p>
<p>This is a good idea and I&#8217;m glad to leave encryption on, but why was it being encrypted differently on the two servers? Suhosin by default uses a couple of different pieces of information as its session encryption key. One of the enabled session encryption options (see the previous link) is &#8220;suhosin.session.cryptdocroot&#8221; which includes the path to the website&#8217;s document root in its encryption key. Since VideoSift and the Wiki are located in a different folder on each server, this was causing the shared session data written by one server to be unreadable (un-decryptable really) by the other server.</p>
<p>There are a couple of obvious solutions, and since I&#8217;d prefer to maintain whatever shreds of security are already in place, I opted to specify a shared session encryption key on both servers (using suhosin&#8217;s suhosin.session.cryptkey option) and disable the suhosin.session.cryptdocroot option. Et voila, she works.</p>
]]></content:encoded>
			<wfw:commentRss>https://rommelsantor.com/clog/2011/02/06/php-shared-session-encoding-solution/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>
