Note that there are some explanatory texts on larger screens.

plurals
  1. POBest practice for dual-use iFrame + External authentication for Facebook enabled app
    primarykey
    data
    text
    <p>Okay, if cookies are a no-no, then I need a little guidance as to the best way to implement the application(s) that I'm creating.</p> <p>The scenario is that I'm trying to create a single Asp.Net MVC application that can authenticate a user regardless of whether the user visits a site directly or via an iFrame in Facebook. There are separate actions (in separate controllers, actually) for getting INTO the app depending on whether the user enters via Facebook or not, but there are also places in the Facebook app where I'm opening up a new window to "extended" functionality in other areas of the application that can't really work well within the iFrame. It is supposed to transition seamlessly. It's currently working quite well using cookies, but I've from multiple sources that this is not a good thing for iFrame apps. However, I'm not sure exactly what this means.</p> <p>Without cookies, can you still somehow get server-side access to the authentication token? If not, then what is the "right" way to handle this. Do I need to resort to manually parsing the token using the JS API and sending an AJAX notification to the server of the fact that the user is authenticated and create a forms auth token? Will the CanvasAuthorize attribute work without cookies? Right now I have added code to the FormsAuthentication_OnAuthenticate event in Global.asax to create the forms auth token if the user is logged in via Facebook (and properly associated with a valid user in the external app) as follows:</p> <pre><code>protected void FormsAuthentication_OnAuthenticate(Object sender, FormsAuthenticationEventArgs args) { if (FormsAuthentication.CookiesSupported) { if (Request.Cookies[FormsAuthentication.FormsCookieName] == null) { // Attempt to authenticate using Facebook try { FacebookApp fbApp = new FacebookApp(); if (fbApp.Session != null) { dynamic me = fbApp.Get("me"); String fbID = "" + me.id; MembershipUser mUser = AppMembershipProvider.GetUserByFacebookID(fbID); if (mUser != null) { FormsAuthentication.SetAuthCookie(mUser.UserName, false); AppMembershipProvider.UpdateLastLogin(mUser.UserName); Session["FacebookLogin"] = true; } } } catch (Exception e) { Elmah.ErrorSignal.FromCurrentContext().Raise(e); } } } else { throw new HttpException("Cookieless Forms Authentication is not " + "supported for this application."); } } </code></pre> <p>Will I need to change this?</p> <p>Sorry if this is basic knowledge, but I'm confused as to how best to implement this. Thanks!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload