<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>giant dancing chipmunk &#187; code</title>
	<atom:link href="http://nessence.net/category/code/feed/" rel="self" type="application/rss+xml" />
	<link>http://nessence.net</link>
	<description>Do you remember when people used browsers?</description>
	<lastBuildDate>Fri, 18 Nov 2011 21:50:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='nessence.net' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>giant dancing chipmunk &#187; code</title>
		<link>http://nessence.net</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://nessence.net/osd.xml" title="giant dancing chipmunk" />
	<atom:link rel='hub' href='http://nessence.net/?pushpress=hub'/>
		<item>
		<title>Locking down Facebook Connect</title>
		<link>http://nessence.net/2010/05/20/facebook-connect-security-lockdown/</link>
		<comments>http://nessence.net/2010/05/20/facebook-connect-security-lockdown/#comments</comments>
		<pubDate>Thu, 20 May 2010 10:36:45 +0000</pubDate>
		<dc:creator>Alex Leverington</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[facebook]]></category>
		<category><![CDATA[facebook connect]]></category>

		<guid isPermaLink="false">http://nessence.net/?p=298</guid>
		<description><![CDATA[UPDATE #2 (10-Oct 2010): Recently  there&#8217;s been a lot of talk over session hijacking, thanks to Firesheep and github. Dang. I liked the term fb-yelp-gibbed. Considerations below still apply. UPDATE: After conversations with a friend, I made a few changes. Specifically, the fbuid is usable on your site, just don&#8217;t use it together with the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nessence.net&amp;blog=7091&amp;post=298&amp;subd=nessence&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>UPDATE #2 (10-Oct 2010):</strong> Recently  there&#8217;s been a lot of talk over <a title="session hijacking" href="http://github.com/blog/737-sidejack-prevention">session hijacking</a>, thanks to <a title="Firesheep" href="http://github.com/codebutler/firesheep">Firesheep</a> and github. Dang. I liked the term fb-yelp-gibbed. Considerations below still apply.</p>
<p><strong>UPDATE:</strong> After conversations with a <a href="http://rodrigofranco.com/">friend</a>, I made a few changes. Specifically, the fbuid is usable on your site, just don&#8217;t use it together with the JS library and don&#8217;t trust the browser.</p>
<p>User privacy is non-negotiable and developers should be as responsible as Facebook.</p>
<p>How to secure your FB Connect Implementation (so your users don&#8217;t get fb-yelp-gibbed):</p>
<p><strong>OLD REST API</strong></p>
<ol>
<li><strong>DON&#8217;T</strong> use the JS library (violating this amplifies your users&#8217; exposure; see EXCEPTION below)</li>
<li>Push all FB connect requests through your backend</li>
<li><strong>DON&#8217;T</strong> STORE a userid or fbid in a cookie (only use fbuid client-side for externals; server should never trust browser-supplied fbuid)</li>
<li><strong>DON&#8217;T</strong> STORE your app&#8217;s FB API &#8220;secret&#8221; client-side (in javascript, in device app, etc.; NO EXCEPTIONS)</li>
<li>DO store your user&#8217;s fbid and/or userid, only, on your server</li>
<li>Never give client-side (JS, scripts, etc.) access to userid or fbid</li>
</ol>
<p>When appropriate, verify the FB user is who they say they are by using auth.* methods, linked below; if you&#8217;re not sure what these do or what they&#8217;re for, give yourself 2-4 weeks to understand the ins and outs. OR, See OAuth comments below (and transition to OAuth).</p>
<p><a href="http://developers.facebook.com/docs/reference/rest/auth.getSession">http://developers.facebook.com/docs/reference/rest/auth.getSession</a></p>
<p>For iPhone/Android, learn how to proxy FB connect requests so you NEVER store your API &#8220;secret&#8221; on the phone.</p>
<p>The only communication between your users browser or device and your fb-app should be whether or not the user has been authenticated. Even then you should also utilize the rest/auth.* (server-side) methods to ensure the user actually authenticated.</p>
<p><strong>NEW OAUTH API</strong><br />
Same as above. NEVER send API calls from JS in the browser! Read the authentication guide and understand every concept:</p>
<p><a href="http://developers.facebook.com/docs/authentication/">http://developers.facebook.com/docs/authentication/</a></p>
<p><strong>EXCEPTION</strong><br />
The only exception here is if there&#8217;s ZERO user-generated content, ZERO 3rd-party HTML, ZERO 3rd-party JavaScript on a page, and everything the page and it&#8217;s assets are all sent via SSL. Even then, you&#8217;re at the mercy of the users desktop &#8212; don&#8217;t store userid, fbuid, or api secret anywhere on the client (in code, cookies, etc.)</p>
<p>The other exception here is if you really know what you&#8217;re doing and you&#8217;ve been dealing with XSS and browser authentication for a decade. In that case, I&#8217;m sure all of your application&#8217;s assets are served statically (or through SSL), your JS is locked down with a fine-tooth comb, you don&#8217;t let any advertisers or user-content sneak in HTML or JS, and you don&#8217;t store your FB API secret on the client.</p>
<p><strong>WHY?</strong><br />
This is serious business. Privacy is priceless. Facebook Connect, despite how folks feel, is more secure than many banks. However, their crutch on letting developers do everything with JavaScript, and browsers limited support for security (injecting JS is like godmode in Doom), have put Facebook at the forefront of all of our security misgivings.</p>
<p><strong>BUT WHAT ABOUT PRIVACY / PAI</strong><br />
A site with a significant user-base and an improper FB Connect implementation will, by proxy, give an attacker delegation to all of the private data that site has access to. Digg being hacked = digg FB users exploited, Yelp exploited = Yelp FB users screwed &#8212; you get the idea.</p>
<p>Please, don&#8217;t be that site. It&#8217;s easy to blame Facebook, but, all they&#8217;ve done is made public data public.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nessence.wordpress.com/298/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nessence.wordpress.com/298/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nessence.wordpress.com/298/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nessence.wordpress.com/298/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/nessence.wordpress.com/298/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/nessence.wordpress.com/298/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/nessence.wordpress.com/298/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/nessence.wordpress.com/298/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nessence.wordpress.com/298/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nessence.wordpress.com/298/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nessence.wordpress.com/298/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nessence.wordpress.com/298/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nessence.wordpress.com/298/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nessence.wordpress.com/298/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nessence.net&amp;blog=7091&amp;post=298&amp;subd=nessence&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nessence.net/2010/05/20/facebook-connect-security-lockdown/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a73a1ab6b15c0f17db9cb7dc7add9a2e?s=96&#38;d=http%3A%2F%2Fs0.wp.com%2Fi%2Fmu.gif&#38;r=X" medium="image">
			<media:title type="html">nessence</media:title>
		</media:content>
	</item>
		<item>
		<title>Amazon RDS: Poison or Pill</title>
		<link>http://nessence.net/2009/10/29/amazon-rds-poison-or-pill/</link>
		<comments>http://nessence.net/2009/10/29/amazon-rds-poison-or-pill/#comments</comments>
		<pubDate>Thu, 29 Oct 2009 11:40:32 +0000</pubDate>
		<dc:creator>Alex Leverington</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[information technology]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[web applications]]></category>
		<category><![CDATA[amazon]]></category>
		<category><![CDATA[amazon rds]]></category>
		<category><![CDATA[aws]]></category>
		<category><![CDATA[cloud]]></category>
		<category><![CDATA[ec2]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[rdbms]]></category>

		<guid isPermaLink="false">http://nessence.net/?p=227</guid>
		<description><![CDATA[As soon as read the AWS newsletter about Amazon RDS, I started looking for a Megaphone to start shouting at folks &#8211; keep away! Amazon RDS or Relational Database Service places Amazon into the mire of shared hosting and AW users into a position of false confidence. Harsh words considering, overall, I feel Amazon&#8217;s service [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nessence.net&amp;blog=7091&amp;post=227&amp;subd=nessence&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>As soon as read the AWS newsletter about Amazon RDS, I started looking for a Megaphone to start shouting at folks &#8211; keep away! Amazon RDS or Relational Database Service places Amazon into the mire of shared hosting and AW users into a position of false confidence. Harsh words considering, overall, I feel Amazon&#8217;s service offerings are best-in-class. AWS offerings have historically pushed the envelope with regard to practical usage-based computing, something which ancient providers such as Sun and IBM have attempted to accomplish for decades; in this case I define practical as both usable and cost effective for small and large tasks. Up until now such systems weren&#8217;t trivialized to x86 hardware and required special programming considerations, access to academic institutions and/or a large budget. By combining SLA-supported x86 virtualization alongside application services such as S3, SQS, and SimpleDB, AWS has provided a usage-based on-demand computing solution which is simpler than task-based computing and as secure and reliable as virtualized or shared hosting. With it&#8217;s on-demand nature AWS is a cost effective for everything from small tasks to those requiring a datacenter of processors.</p>
<p>So why is Amazon RDS so bad, so much that you shouldn&#8217;t use it?</p>
<p>Well, there&#8217;s not an easy answer, the better question is to ask yourself: Why do you think AWS will be better than your own MySQL deployment? There is no right answer because almost any answer will probably, one day, bite you in the ass. Hard. I mean data loss, and it won&#8217;t be Amazon&#8217;s fault.</p>
<p>RDBMS systems and applications which depend on them are built from the ground up to rely on persistence, integrity, and static data models (schema). In contrast AWS has been built for distribution, decentralization, and the &#8220;cloud&#8221;. For Amazon, this service is somewhat of a U-turn from their original direction and has also placed a stamp on their forehead which says &#8220;That MySQL Guy&#8221; which is not good &#8212; I have nothing against mysql, however, as a de facto entry-level (free open source) software, it has accrued a strong following of immature software. Such software has nothing to do with the basic purposes of AWS or MySQL but has everything to do with how Amazon&#8217;s support and engineering staff will be spending their time which is supporting users and software which aren&#8217;t built for the cloud.</p>
<p>I hope that RDS won&#8217;t be a situation of butterflies &amp; hurricanes but here&#8217;s a quick list of why the relative cost of RDS is high both for Amazon (the company) and all of it&#8217;s AWS users:</p>
<ul>
<li>Cost for Amazon (operations, engineers, and products)
<ul>
<li>MySQL, like most open source systems, has been historically buggy software with a trailing release+testing+production schedule which requires continuous testing between production releases for large deployments (such as RDS).</li>
<li>MySQL has a large set of features which vary across releases and which share equal presence in production; in other words, Amazon will need to cater to providing production support for multiple versions, not just the latest stable version.</li>
<li>Amazon has no control over features and capabilities of MySQL and is thus limited to what MySQL provides; while MySQL provides many &#8220;good things&#8221;, Amazon will still be obligated to maintain through the bad. This is a shared disadvantage of AWS Map Reduce via Hadoop however, those are mostly mitigated because Map Reduce is such a low-level distributed system.</li>
<li>MySQL is very flexible and itself scales very well however it doesn&#8217;t do so by itself and requires a significant effort to be properly configured for the data being managed. All the folks who don&#8217;t know this will default into thinking Amazon will do this for them and will be disappointed when it doesn&#8217;t &#8220;just work&#8221;. Whether they ditch RDS or bug Amazon&#8217;s support, either way, it&#8217;s not a positive situation.</li>
</ul>
</li>
</ul>
<ul>
<li>Cost for AWS (primarily EC2) users
<ul>
<li>Potential degradation of service and support for EC2 instances
<ul>
<li>With RDS available Amazon can defer issues with regard to running MySQL on EC2 instances to a recommendation for RDS &#8212; this will be a terrible waste of time for both parties.</li>
<li>MySQL is a very centralized system and by transitioning the decision of where MySQL resides in the AWS cloud from the user to Amazon, Amazon will be further centralizing the impact of MySQL on the cloud. Whereas users will randomly have MySQL deployed across any EC2 instance, Amazon will be appointing MySQL to specific hardware; this is based on the assumption that Amazon is clustering RDS deployments onto local hardware and not randomly deploying instances in the cloud. This is somewhat of a compromise for security and adds significant SLA risks (read: cost) to Amazon. In short, when a MySQL cluster dies &#8211; a LOT of folks are going to be VERY unhappy &#8211; their support tickets will be a burden to staff and their requests for credits will be a financial cost. Moreover, support staff will be yielding priority to these customers over other services because of the implicit severity.</li>
</ul>
</li>
<li>Increased cost
<ul>
<li>RDS instances cost &gt;10% more than regular instances and only come with the added benefit of backups &#8212; something which every system should already have in place. If you do choose to delegate the task of backups to RDS, you&#8217;re paying extra for a task you&#8217;ve already thought about doing yourself.</li>
<li>Cost of keeping your database, it&#8217;s backups, and it&#8217;s history all within AWS is multiplicative and if you grow to the point where you&#8217;re ready to move off you&#8217;ll be charged to transfer all the data to an external system. While this is a subjective cost it&#8217;s still worth pointing out; if folks aren&#8217;t already doing backups right, they&#8217;ll likely not know that cost effective database backups make use of binary logging facilities, not filesystem snapshots, and use significantly less disk space (and thus I/O).</li>
</ul>
</li>
<li>False confidence
<ul>
<li><a title="magnolia dead" href="http://nessence.net/2009/02/18/magnolia-ded/">As I&#8217;ve mentioned before, letting other folks control your backups for you is a mistake</a>. Failure is a matter of when, not if, and you&#8217;ll be in better control of responding if you understand what you&#8217;re dealing with. Just because RDS is doing you&#8217;re backups doesn&#8217;t mean you&#8217;re safe.</li>
<li>RDS users will expect MySQL to scale on-demand as everything else works that way with AWS and it&#8217;s just not that simple. Scaling a database requires analysis and a balanced combination of server settings, data normalization, and indexes; all of these things will still be the user&#8217;s responsibility and Amazon&#8217;s solution of &#8220;throw hardware at it&#8221; is a haunted path to send it&#8217;s users down.</li>
</ul>
</li>
</ul>
</li>
</ul>
<p>Overall, I feel that Amazon could quickly cannibalize the value and quality of AWS if they (continue to) introduce trivial services. Supporting open source software they have no control over is a significant increase in relative support and operations cost. Amazon seems to be approaching this by making the cost of RDS instances more than EC2 which is a mistake because the real cost is the lost opportunity of engineers spending their time on systems which are more efficient for cloud computing &#8211; Amazon could charge 3 times an EC2 instance and their engineers would still be better off building technologies for cloud-based systems and not centralized RDBMS-dependent web applications.</p>
<p>Where I feel Amazon has fallen short the most, is that RDS only provides single-instance MySQL support and nothing more. No load balancing, replication, Hadoop integration, or any other form of data abstraction which could make it functional in a cloud computing context. Not implementing these features is a very clear indicator that AWS is focused more on short term revenue generating feature rather than cost effective cloud computing systems or improving the shortfalls of legacy centralized system.</p>
<p>With all this said, I have to consider the possibility of this being a good move for Amazon. I present the potential issues with RDS simply to warn folks from relying on it as a crutch, and, to point out the new direction AWS has veered is into choppy waters. There are several aspects of RDS which will give Amazon insight into correlations among and between the varying systems of data storage and processing &#8211; comparing SimpleDB, MapReduce, MySQL, and general resource consumption could shed light onto how their cloud is being used at a higher level than processors and bandwidth. Last, Amazon might be aware that MySQL is a crutch and is putting the service out there as a way to wean folks off of centralized systems.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nessence.wordpress.com/227/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nessence.wordpress.com/227/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nessence.wordpress.com/227/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nessence.wordpress.com/227/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/nessence.wordpress.com/227/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/nessence.wordpress.com/227/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/nessence.wordpress.com/227/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/nessence.wordpress.com/227/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nessence.wordpress.com/227/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nessence.wordpress.com/227/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nessence.wordpress.com/227/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nessence.wordpress.com/227/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nessence.wordpress.com/227/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nessence.wordpress.com/227/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nessence.net&amp;blog=7091&amp;post=227&amp;subd=nessence&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nessence.net/2009/10/29/amazon-rds-poison-or-pill/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a73a1ab6b15c0f17db9cb7dc7add9a2e?s=96&#38;d=http%3A%2F%2Fs0.wp.com%2Fi%2Fmu.gif&#38;r=X" medium="image">
			<media:title type="html">nessence</media:title>
		</media:content>
	</item>
		<item>
		<title>restful-authentication + subdomain-fu = needing cookie adjustments</title>
		<link>http://nessence.net/2009/10/26/restful-authentication-subdomain-fu-needing-cookie-adjustments/</link>
		<comments>http://nessence.net/2009/10/26/restful-authentication-subdomain-fu-needing-cookie-adjustments/#comments</comments>
		<pubDate>Mon, 26 Oct 2009 09:45:49 +0000</pubDate>
		<dc:creator>Alex Leverington</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[web applications]]></category>
		<category><![CDATA[CGI]]></category>
		<category><![CDATA[cookie]]></category>
		<category><![CDATA[rack]]></category>
		<category><![CDATA[rails 2.3]]></category>
		<category><![CDATA[rails sub-domain subdomain restful-authentication subdomain-fu]]></category>

		<guid isPermaLink="false">http://nessence.net/?p=224</guid>
		<description><![CDATA[I&#8217;ve perused several posts about handling cookies when multiple subdomains are involved however, the solutions were either for older versions of rails or didn&#8217;t resolve my situation; we wanted to have a cookie which could be used among all subdomains. This might also give you some insight as to why restful-authentication doesn&#8217;t have a feature [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nessence.net&amp;blog=7091&amp;post=224&amp;subd=nessence&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve perused several posts about handling cookies when multiple subdomains are involved however, the solutions were either for older versions of rails or didn&#8217;t resolve my situation; we wanted to have a cookie which could be used among all subdomains. This might also give you some insight as to why restful-authentication doesn&#8217;t have a feature to do all this for you &#8212; it keeps changing and by-hand is best for now. If you&#8217;re employing this, do be diligent with security; sharing credentials across domains can be risky business if your security varies across domains.</p>
<p>To do this, first edit config/initializers/session_store.rb where you&#8217;ll want to add the key:</p>
<p>:domain =&gt; &#8216;.example.com&#8217;</p>
<p>The format here is important &#8211; if you don&#8217;t prefix the domain with a period the cookie (and session) will not apply for requests to subdomains. This covers the rails session &#8212; however we also need to cover the cookie set by restful-authentication which you&#8217;ll find in lib/authenticated_system.rb. In the kill_remember_cookie! and send_remember_cookie! methods insert same key as above or a reference to the session_options key. It&#8217;ll look like this:</p>
<pre>def kill_remember_cookie!
  cookies.delete :auth_token, :domain =&gt; ActionController::Base.session_options[:domain]
end</pre>
<pre>def send_remember_cookie!
  cookies[:auth_token] = {
    :value   =&gt; @current_user.remember_token,
    :expires =&gt; @current_user.remember_token_expires_at,
    :domain =&gt; ActionController::Base.session_options[:domain] }
end</pre>
<p>During development you should be aware this might not work using &#8216;localhost&#8217;, depending on your OS. The best thing to do is to edit your hosts file to have &#8220;example.local&#8221; point to your machine and use those domains for testing instead.</p>
<p>If you&#8217;re doing anything more complicated, you&#8217;ve got your work cut out for you as you may need to write custom rack middleware (see: Google) and/or use a Proc. In the latest Rails, cookies are being handled by Rack (instead of CGI); in any version, setting Cookies via cookies[:key]= is performed independent of the session options which is why you must specify the domain separately. There are some folks who describe monkey patching Rails to set the domain automatically but this is unreliable as I believe it&#8217;s changed every release. If you don&#8217;t want to have to change it, just create a wrapper method for setting your cookies, or, set the domain wherever you set or delete a cookie. We only set one cookie via restful-authentication so 2 lines is a fairly simple fix.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nessence.wordpress.com/224/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nessence.wordpress.com/224/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nessence.wordpress.com/224/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nessence.wordpress.com/224/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/nessence.wordpress.com/224/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/nessence.wordpress.com/224/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/nessence.wordpress.com/224/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/nessence.wordpress.com/224/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nessence.wordpress.com/224/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nessence.wordpress.com/224/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nessence.wordpress.com/224/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nessence.wordpress.com/224/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nessence.wordpress.com/224/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nessence.wordpress.com/224/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nessence.net&amp;blog=7091&amp;post=224&amp;subd=nessence&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nessence.net/2009/10/26/restful-authentication-subdomain-fu-needing-cookie-adjustments/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a73a1ab6b15c0f17db9cb7dc7add9a2e?s=96&#38;d=http%3A%2F%2Fs0.wp.com%2Fi%2Fmu.gif&#38;r=X" medium="image">
			<media:title type="html">nessence</media:title>
		</media:content>
	</item>
		<item>
		<title>PHP4 + PHP5 compatible overloading</title>
		<link>http://nessence.net/2008/05/01/php4-php5-compatible-overloading/</link>
		<comments>http://nessence.net/2008/05/01/php4-php5-compatible-overloading/#comments</comments>
		<pubDate>Thu, 01 May 2008 10:23:37 +0000</pubDate>
		<dc:creator>Alex Leverington</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[oop overloading polymorphism php4 php5]]></category>

		<guid isPermaLink="false">http://nessence.wordpress.com/?p=23</guid>
		<description><![CDATA[While I don&#8217;t necessarily enjoy PHP, it&#8217;s not such a terrible language. At least for version 5. Lately I&#8217;ve been working on a project called &#8216;migrations&#8217; which is essentially a PHP utility to generate / track / apply changes to a database in a similar fashion to the migrations system in Ruby on Rails. Of [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nessence.net&amp;blog=7091&amp;post=23&amp;subd=nessence&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>While I don&#8217;t necessarily enjoy PHP, it&#8217;s not such a terrible language. At least for version 5. Lately I&#8217;ve been working on a project called &#8216;migrations&#8217; which is essentially a PHP utility to generate / track / apply changes to a database in a similar fashion to the migrations system in Ruby on Rails. Of course, it&#8217;s got more magic than migrations (only because we know we&#8217;re going to use subversion) and it&#8217;s got to work with PHP4.</p>
<p>Let&#8217;s get back to the subject though. When writing any type of class that needs to be polymorphic or &#8216;dynamic&#8217; in a sense that method calls can be made when a pre-defined method doesn&#8217;t exist, then &#8216;overloading&#8217; is the magic PHP provides to satisfy your needs. As a note, polymorphism is simply the ability of a method to take varying parameters or by which a different method will be executed based on the types and/or quantity of methods required. For example, you could have a different method defined for function($array) than function($string). PHP doesn&#8217;t care about types and so doesn&#8217;t support polymorphism <em>per se</em> but by using overloading you can essentially accomplish the same thing. In my case however, I&#8217;m simply wanting to allow execution of non-existent methods against on object. The purpose is that I want to be able to log each method call and it&#8217;s result in order to track what&#8217;s going on. You&#8217;ll quickly see what I mean in the examples.</p>
<p>PHP5 Basic Example:</p>
<pre>class dynamicClass {
    function __call($method, $arguments) {
        trigger_error('Call to undefined method ' . __CLASS__ . '::' . $method . '()', E_USER_ERROR);
    }
}</pre>
<p>Now have a class in PHP5 with overloading enabled. Without trigger_error, PHP will always think that you&#8217;re calling a valid method! In PHP5, there is no way to tell the interpreter the called method is invalid and you are responsible for triggering an error.</p>
<p>PHP4 Basic Example:</p>
<pre>class dynamicClass {
    function __call($method, $arguments, &amp;$return) {
        if($method == __CLASS__)
            return true;

        trigger_error('Call to undefined method ' . __CLASS__ . '::' . $method . '()', E_USER_ERROR);
    }
}</pre>
<p> <br />
In PHP4, overloading was experimental for awhile and is now not well documented because it changed so much in PHP5. The first two lines of the __call method exist because the class doesn&#8217;t have a constructor defined but we don&#8217;t want to return false or null &#8211; if we do &#8211; PHP will throw a warning that we made a call to an undefined method, as it tries to call the non-existent constructor. Without overloading PHP4 ignores non-existent constructors, however, since we&#8217;ve overloaded and the constructor doesn&#8217;t already exist &#8211; PHP4 hits __call. This is different from PHP5 wherein PHP5 will not try to make an overload call for any constructor. This is likely because in PHP5 constructors or pseudo-static methods (they are not called within the context of an object even though the constructor has access to the object &#8211; this is why you get to use the $this variable even in a static context &#8211; if you couldn&#8217;t PHP5 constructors wouldn&#8217;t work ;) )</p>
<p>So between these two examples we can see some obvious limitations.</p>
<ol>
<li>don&#8217;t use overloading for anything regarding constructors</li>
<li>php4 uses &amp;$return declaration for return, php5 uses return()</li>
<li>php4 is the exception, not php5; php5 autoload will work just fine</li>
<li>in php4, you&#8217;re class is limited to being declared from within an eval() block</li>
</ol>
<p>This makes for complications if you want to create a class with overloading which will work both in PHP4 and PHP5. There is the safe way, not-so-safe way, and the somewhat-safe way that&#8217;s a little slower! First, I&#8217;ll show you the not-so-safe way which I&#8217;ll be using simply because this is a utility and not something I expect someone to modify and <em>secondly</em> because integration tests tell me if/when something breaks. If you don&#8217;t write tests I would highly recommend the &#8216;safer&#8217; way.</p>
<p>File &#8211; dynamicOverloaded.class.php:</p>
<pre>class dynamicOverloaded {
    function __call($method, $arguments /*PHP4, &amp;$return*/) {
        /*PHP4if($method == __CLASS__) return true;*/

        // You're overloading logic

        $return = $resultFromYourMagic;
        return ($return ? $return : true);
    }
}</pre>
<p>You maybe asking yourself now &#8220;wtf&#8221; or &#8220;how is that supposed to work?&#8221; and you would be right &#8211; it&#8217;s not going to work yet. In order to make this work, you can&#8217;t require() or include(), or otherwise execute this file. Unless of course, the version of PHP is &gt;= 5, in either case, the following code will do the trick.</p>
<p>The not-so-safe way:</p>
<pre>if(substr(PHP_VERSION, 0, strrpos(PHP_VERSION, '.')) &lt; 5)
    eval('?&gt;' . preg_replace('|/\*PHP4(.*?)\*/|', '\\1', file_get_contents('path/to/dynamicOverloaded.class.php')) );
else
    require_once('dynamicOverloaded.class.php');</pre>
<p>As with any php script, you have to include it. But in this case we&#8217;re eval()&#8217;ing the contents of the file instead of including it when using PHP4. Before eval we&#8217;re stripping /*PHP4 */ comments and leaving the code within it intact. The result? It&#8217;s like pre-compile macros for PHP. This is called the not-so-safe way primarily due to all of the limitations and bugs from eval().</p>
<p>But what is the safe method, and what if I&#8217;m doing something eval() doesn&#8217;t like?</p>
<p>In this case, you want to change your code to check for the version of PHP &#8211; create one class called yourClass.class4.php and yourclass.class.php; if using PHP4&#8230; you get the idea. Make your require() statements dynamic. The class4.php script will have the same code but you&#8217;ll remove the /*PHP4 */ comments before you save the file (leave the code between the comment markers in place). As you can see the real trick is to have your classes declared in separate files. The problem with this and the reason it&#8217;s not called &#8220;safe&#8221; is because you&#8217;re going to have to keep your changes to the class synchronized across both files at all times! While annoying, you can be happy know that you&#8217;re not eval()&#8217;ing code or executing temporary files.</p>
<p>But what if I don&#8217;t want to have to keep changes synchronized between class files and I don&#8217;t mind it being a <strong>tiny bit</strong> slow?</p>
<p>Before requiring the class file so you&#8217;ll want to name the base class yourClass.classX.php with the /*PHP4 */ blocks of code in it &#8211; before performing require() you literally &#8216;compile&#8217; the class by running the preg_replace and saving the result to a temp file on disk; then require() the tmp file and delete the tmp file. Now obviously there can be some risks associated with executing a file which is written to disk by the executing process (esp if it&#8217;s a web server) but you can do a few things such as making the file name random to mitigate risks. Whatever you do, be sure the temporary location is relatively safe (consult chmod man page) and that above all the generated script is deleted after it&#8217;s executed.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/nessence.wordpress.com/23/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/nessence.wordpress.com/23/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nessence.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nessence.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nessence.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nessence.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/nessence.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/nessence.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/nessence.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/nessence.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nessence.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nessence.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nessence.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nessence.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nessence.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nessence.wordpress.com/23/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nessence.net&amp;blog=7091&amp;post=23&amp;subd=nessence&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nessence.net/2008/05/01/php4-php5-compatible-overloading/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a73a1ab6b15c0f17db9cb7dc7add9a2e?s=96&#38;d=http%3A%2F%2Fs0.wp.com%2Fi%2Fmu.gif&#38;r=X" medium="image">
			<media:title type="html">nessence</media:title>
		</media:content>
	</item>
		<item>
		<title>Coding like it&#8217;s 1999</title>
		<link>http://nessence.net/2008/04/25/coding-like-its-1999/</link>
		<comments>http://nessence.net/2008/04/25/coding-like-its-1999/#comments</comments>
		<pubDate>Fri, 25 Apr 2008 04:25:18 +0000</pubDate>
		<dc:creator>Alex Leverington</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[web applications]]></category>
		<category><![CDATA[!microsoft]]></category>
		<category><![CDATA[bitter soap]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[lisp]]></category>
		<category><![CDATA[perl died]]></category>
		<category><![CDATA[SOAP]]></category>
		<category><![CDATA[top ten]]></category>

		<guid isPermaLink="false">http://nessence.wordpress.com/?p=17</guid>
		<description><![CDATA[Here is my top ten list of &#8220;How to code like it&#8217;s 1999&#8243;: 1. using PHP &#60; 5.3 (4 was beta in 1999) 2. making use of perl for *anything* (see #4) 3. template engines (scope and variable interpolation exist for a reason) 4. Perl6 (active 1999 mailing list) 5. Java Web Applets 6. SELECT [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nessence.net&amp;blog=7091&amp;post=17&amp;subd=nessence&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Here is my top ten list of &#8220;How to code like it&#8217;s 1999&#8243;:</p>
<p>1. using PHP &lt; 5.3 (4 was beta in 1999)<br />
2. making use of perl for *anything* (see #4)<br />
3. template engines (scope and variable interpolation exist for a reason)<br />
4. Perl6 (active 1999 mailing list)<br />
5. Java Web Applets<br />
6. SELECT * FROM (seriously, get ORM, select only what you need, or quit your day job.)<br />
7. lisp (like a hero from a classic book, tragic)<br />
8. non-functional redirect pages (hello js or location header; good-bye bad knocking off a lame phpbb feature)<br />
9. ActiveX plug-ins (who developers sites with IE, anyways?)<br />
10. SOAP (all your interoperability are belong to SOAP)</p>
<p>In short, if your core application for which your business and revenue suffers any of the above atrocities, step back for a minute and ask yourself if you <strong>really</strong> know any better? If you don&#8217;t, hire someone who does &#8211; FAST!</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/nessence.wordpress.com/17/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/nessence.wordpress.com/17/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nessence.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nessence.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nessence.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nessence.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/nessence.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/nessence.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/nessence.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/nessence.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nessence.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nessence.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nessence.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nessence.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nessence.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nessence.wordpress.com/17/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nessence.net&amp;blog=7091&amp;post=17&amp;subd=nessence&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nessence.net/2008/04/25/coding-like-its-1999/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a73a1ab6b15c0f17db9cb7dc7add9a2e?s=96&#38;d=http%3A%2F%2Fs0.wp.com%2Fi%2Fmu.gif&#38;r=X" medium="image">
			<media:title type="html">nessence</media:title>
		</media:content>
	</item>
	</channel>
</rss>
