javascript - Facebook Connect help -
According to the Facebook API documentation, most of the work is done via Javascript
This means that All processing is done, and then front end checks that the user is connected to facebook / authorized. right?
My question is:
Suppose a user first visits my site. He clicks on "Facebook Connect" Javascript verifies it as authentic, and it "redirects" to the second page on my server, since then, how will I know that the user is actually authenticated on my website because Everything is done on the forehead?
I think this is correct, but there are not some security problems ..:
- Login after user, a page on Facebook Redirects my site to And they also make a cookie with a specific "Facebook ID" that is only obtained from this user. Please "read" my supported cookies and grab that ID ... and then add it to my user id.
If this is correct ... then it does not understand. What if people steal other people's "Facebook IDs" and then make cookies? And then looks at my backend cookie and thinks this is the real user ...?
Am I confused? If I am confused, then help me rearrange and tell me how it is.
Facebook Connect uses a clever (or crazy, depending on your hypocrisy) Hack into the browser to get cross-site communication between your site and the authentication system of Facebook.
The way this works, it is as follows:
- Your site contains a very simple static HTML file, which is a cross-domain communication channel This file is known as the
xd_receiver.htm
in the FB docs, but it can be given a name for you. - Your site's login page contains a reference to the JavaScript library hosted on Facebook's server.
- When a user logs via the "Connect" button, then he calls a function in Facebook's JS API, which pops up a login dialog. This login box has an invisible
iframe
, in which the cross-domain communication file is full. - The user fills the form and submits it, posts the form to Facebook.
- Checks Facebook Login If it is successful, then it communicates on your site. Here's where cross-domain comes:
- Due to cross-domain security policies, Facebook's login window can not inspect the DOM tree for documents hosted on your server. But within the login code
src
can update the contents of anyiframe
, and with the hosted cross-domain communication file Used to communicate on your page. - When a cross-domain communication file receives a hint that the entry is successful, it uses JavaScript to set some cookies with the user's ID and session. Since this file resides on your server, those cookies have your domain and your backend can get them.
- Due to cross-domain security policies, Facebook's login window can not inspect the DOM tree for documents hosted on your server. But within the login code
- Any other communication towards Facebook can be completed by inserting another nested code
Cookies are secure (in theory) because the data is signed with the secret key, which you generated for Facebook when you signed up for the developer program. The JS library uses your public key ("API key") to validate cookies.
Theoretically, Facebook's JavaScript Library lets you handle everything automatically after you've set everything in practice, I've found that it does not always work smoothly at all. For a more detailed description of the mechanics of cross-domain communication using
iframe
s, see from MSDN.
Comments
Post a Comment