I am currently developing a SSO website-network.
It has a few websites wich are unfortunately all separate domains like:
- domain.de
- domain-specials.de
- domain-otherthings.de
- somethingelse.de
I have managed to create a SSO using JSONP / Ajax, so when you login to any of the sites you are signed on into the others as well.
Now i need to implement a “login with facebook” feature that works with the current SSO.
The problem here is that a facebook app can only have one root domain to work with so if you try to use the Facebook-App on another website you mostly get security errors.
I tried the Facebook Client-Side Authentication which of course doesn’t work on any other site than the one I created the Facebook-App for:
API Error Code: 191
API Error Description: The specified URL is not owned by the application
I also tried using a channel file in the FB.init which is currently used on all websites:
FB.init({
appId : '1234567890', // app id
channelUrl : 'http://www.domain.de/channel.html', // fqd-path to channel file
status : true, // check login status
cookie : true, // allow the server to access the session
xfbml : true, // parse XFBML
oauth : true // ?
});
Now I am currently experimenting with the Server-Side Authentication but I am still unsure if there isn’t a better way to solve this problem since it forces me to redirect to the domain I used in the Facebook-App.
The main problem here being the user flow.
The client flow is quite nice
- Click login with Facebook
- Facebook popup
- Click yes or no
- Done!
While the server flow is not so fluid
- Click login with Facebook
- Redirect to Facebook
- Click yes or no
- Redirect to root domain
- Somehow redirect to originating domain
- Done!
I have also thought about creating an app for every single site; but that is just stupid.
So, if anyone knows a better solution to this problem or if anything needs more clarification, please let me know.
Regards
In the end I had to create a little workaround. By using a designated landing script for all logins I was able to redirect the users back to the refering page.
This Facebook link redirects to http://mydomain.de/fb_connect/1/
[your_app_id] = Facebook App Id
[your_domain] = http://www.domain.com or whatever your domain is
[domain_id] = I used this to know from where the user came
[some_hash] = used by Facebook to prevent xsrf
Then I had a little PHP-Script prepared to process the incoming data using apaches mod_rewrite
.htaccess in the fb_connect folder on my server
And in the index.php I used something like this
This pretty much does the trick for me. If you have any questions feel free to ask.
Regards