Moonbase7

cf_space

September 12, 2009 - 12:33 PM (GMT)

Category: Coldfusion,Notes,OpenID
Author: Charles

I was recently integrating OpenID into my SaaS Intranet offering over at CompositeWeb.  I started working with the opensource project OpenID at riaforge.  It worked great, but then I found the RPXnow site and thought it would provide a lot more flexibility in the future and provide for an easier to maintain interface.

I didn't find any information on how to implement it with coldfusion so I thought I would post what I figured out.

Keep in mind this is a simplified version of validation and using the PRXnow api to get data about the user.  You need to signup for an account at RPXnow (which they do offer a free version of).  You will also need to go to CFLib.org to download the jsondecode UDF so that you can parse the json data that the api returns.  In the code below I have cfincluded the udf.

<cfinclude template="jsondecode.cfm">

<cfset token_url = "http://the url where your page is">
<cfset apiKey = "your api key">

<cfif isdefined('url.token')>
	<!--- RPXnow returns a token that you can then use against their API to get the user info --->
	<cfhttp method="post" url="https://rpxnow.com/api/v2/auth_info" >
		<cfhttpparam type="formfield" name="apiKey" value="#apiKey#" />
		<cfhttpparam type="formfield" name="token" value="#url.token#" />
	</cfhttp>
	<cfset retStruct = jsondecode(cfhttp.FileContent)>
	<cfdump var="#retStruct#">
	<cfif retStruct.stat eq 'ok'>
		<h1>Logged In</h1>
	<cfelse>
		<h1>Not</h1>
	</cfif>
</cfif>



<cfoutput>
<a class="rpxnow" onclick="return false;"
   href="https://the url they give you.rpxnow.com/openid/v2/signin?token_url=#token_url#">Sign In</a>
</cfoutput>
<script src="https://rpxnow.com/openid/v2/widget" type="text/javascript"></script>
<script type="text/javascript">
  RPXNOW.overlay = true;
  RPXNOW.language_preference = 'en';
</script>

Once you run that, and you successfully login, it will dump out the data provided by the openid provider. RPXnow also has some great documentation on their site if you need to dig a little deeper.

Good luck!


Share/Save/Bookmark

Comments:
No comments

Archives:
November 2008 (1)
December 2008 (2)
May 2009 (2)
June 2009 (1)
July 2009 (1)
September 2009 (3)
October 2009 (1)
December 2009 (1)
January 2010 (3)
July 2010 (1)

Categories:
Coldfusion (7)
CompositeWeb (1)
coreforms (3)
Crazy Ideas (1)
fun (2)
mac (3)
nature (1)
Notes (4)
OpenID (1)
Space (1)
tech notes (4)
video (1)
wiki (1)

Authors:
Charles (16)

Search:

rss feed All
rss feed Charles

This is the weblog of Charles Kaufmann.  All thoughts and opinions are solely his own (you wouldn't want them anyway).

Collaboration Suite

Are you looking for a way to get your group/company/non-profit to share files, calendars, forums, and more? CompositeWeb is offering a hosted Collaboration Suite solution so you have no IT costs, just an inexpensive monthly fee.  Try it for 30 days free!

Need some CMS?

If you are looking to create a site like this, check this out!  You can get a full featured site for free, all you have to do is sign up and add content.