<?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>Dan Theurer &#187; sso</title>
	<atom:link href="http://www.theurer.cc/blog/category/sso/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.theurer.cc/blog</link>
	<description>Web services, technology and random thoughts!</description>
	<lastBuildDate>Thu, 28 May 2009 03:21:34 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>BBAuth Coding &#8211; Single Sign On</title>
		<link>http://www.theurer.cc/blog/2006/09/29/bbauth-coding-single-sign-on/</link>
		<comments>http://www.theurer.cc/blog/2006/09/29/bbauth-coding-single-sign-on/#comments</comments>
		<pubDate>Fri, 29 Sep 2006 17:34:49 +0000</pubDate>
		<dc:creator>Dan</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web services]]></category>
		<category><![CDATA[sso]]></category>

		<guid isPermaLink="false">http://www.theurer.cc/blog/2006/09/29/bbauth-coding-single-sign-on/</guid>
		<description><![CDATA[I put together a BBAuth sample to test the userhash / SSO feature and you can download the source code for it. The application uses a database connection to store the userhash and the data that the user submitted. If you want to use it for more than just a sample I recommend adding error [...]]]></description>
			<content:encoded><![CDATA[<p>I put together a <a href="http://theurer.cc/code/sso">BBAuth sample</a> to test the userhash / SSO feature and you can <a href="http://theurer.cc/code/sso/sso.zip">download the source code</a> for it. The application uses a database connection to store the userhash and the data that the user submitted. If you want to use it for more than just a sample I recommend adding error handling.</p>
<p>To make the sample work you need to get your own appid:</p>
<ol>
<li>Go to <a href="https://developer.yahoo.com/wsregapp/">https://developer.yahoo.com/wsregapp/</a></li>
<li>Fill in your info &#8211; The Web Application URL is where Yahoo! redirects the user after he signs in successfully. This should be PATHTOTHEFILES/success.php</li>
<li>Pick the scope that is called something like &#8220;Yahoo Authentication, no user data access&#8221; (SSO)</li>
<li>Follow the steps in the flow until you get your appid / secret</li>
<li>Enter both in the <strong>bbauth.inc</strong> file where it says appid and secret.</li>
<li>At this point the redirect to Yahoo and redirect back to the server should work, but the success.php will fail because of the missing database.</li>
<li>Set up a database &#8211; feed <strong>sso.sql</strong> to your db</li>
<li>Enter the database info in <strong>success.php </strong>where it says &#8220;Edit your info here:&#8221;<strong><br />
</strong></li>
<li>Now it should run like a Prius in the carpool lane.</li>
</ol>
<p><span id="more-52"></span><br />
Let&#8217;s start with the <strong>index.php</strong> page. Index has only two lines of actual code, everything else is markup:<br />
<code>< ?php<br />
//pulls in the bbauth functionality / appid / secret<br />
include "bbauth.inc";</code><br />
</code><code>//sign the redirect url and request userhash (send_userhash=1)<br />
$app_login_url =  yahoo_sign_url ( $wslogin_server_long . "?appid=" . $appid . "&#038;send_userhash=1", $secret );<br />
?></code></p>
<p><strong>bbauth.inc </strong>contain the yahoo_sign_url and others functions that are needed to deal with that Yahoo! login servers. The three functions listed below make the authentication flow pretty clear.</p>
<p><code>yahoo_sign_url( $url, $secret )</code><br />
Signs the the URL that sends the user to the Yahoo! login server with your secret. That lets Yahoo ensure that the request comes from someone who has the secret. The user logs in and get redirected to your app.</p>
<p><code>function yahoo_sig_validate( $secret)</code><br />
This function validates the signature that that is attached to the URL where the login server sends the user after he or she signs in successfully. This protects your app from someone forging a request. The request will also contain a token that can be used to request a cookie.<code /></p>
<p><code>get_cookie( $url )</code><br />
Once you have the token you can request a cookie to make calls on behalf of the user - that is not part of the SSO sample. Jason put a <a href="http://developer.yahoo.com/auth/quickstart/bbauth_quickstart.zip">quick start guide</a> on YDN that talks about that in more detail.</p>
<p><strong>success.php</strong> gets called when the user get redirected back to your app and the signature gets validated. After that it's some html / sql to get some content on the screen</p>
<p><strong>sso.sql</strong> creates a table called 'sso' with five columns.</p>
<p>Let me know if you have any feedback.</p>
<p>Another really cool SSO sample is the one from <a href="http://kentbrewster.com/ybbs/">Kent Brewster</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.theurer.cc/blog/2006/09/29/bbauth-coding-single-sign-on/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
