2011年11月13日 星期日

[Facebook] Authentication

  • Uses the OAuth 2.0 protocol for authentication and authorization.
  • Support for Website, mobile and desktop apps.


Supports two different OAuth 2.0 flows for user login
  • Server-side
    • The authentication code flow in the specification.
    • Used whenever you need to call the Graph API from your web server.
  • Client-side
    • The implicit flow.
    • Used when you need to make calls to the Graph API from a client.
    • ex: JavaScript running in a Web browser or from a native mobile or desktop app.


Implementation of the OAuth 2.0 involves three different steps
  • User authentication
    • Ensures that the user is who they say they are
  • App authorization
    • Ensures that the user knows exactly what data and capabilities they are providing to your app.
  • App authentication
    • Ensures that the user is giving their information to your app and not someone else.


Server-side Flow



Client-side Flow



Alternate Redirect URIs
  • Specifying additional App Domains for your app is useful for redirecting users to other servers for geographic distribution of load.
  • When redirect_uris are specified in the authentication flows, the user is normally redirected to a path under the Site URL that you specify in the Basic Info section on the Summary tab in the Developer App
  • However, you can override this behavior and redirect to one or more other related or sub-domains by specifying each domain name in the App Domain field in the Basic Info section of the Summary Tab in the Developer App


You can log a user out of their Facebook session by directing them to the following URL:
https://www.facebook.com/logout.php?next=YOUR_URL&access_token=ACCESS_TOKEN


Also support
  • App Login
  • Page Login


Cross Site Request Forgery (CSRF)
  • Cross site request forgery is an attack in which a trusted (authenticated and authorized) user unknowingly performs an action on website.
  • To prevent this attack, you should
    • Pass an identifier in the state parameter
    • Validate the state parameter matches on the response. 
  • We strongly recommend that any app implementing Facebook user login implement CSRF protection using this mechanism.



Related
[Security] OAuth and OpenId


* Reference
- Authentication

沒有留言:

張貼留言