Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changes for token_url flexibility #2

Merged
merged 1 commit into from Apr 2, 2012
Merged

Conversation

fschwiet
Copy link
Contributor

@fschwiet fschwiet commented Apr 1, 2012

Hi Troy, thanks again for making your code available on github and now nuget, it made it easy to get going to Janrain Engage.

I ran into an issue though getting it to work with forms authentication. I wanted to use the "AuthorizeAttribute", which will redirect unauthorized users to the login page, with the ReturnUrl querystring parameter. The user is redirected to ReturnUrl after logging in successfully. To make this work with EngageNet, I needed to include this querystring parameter in the token_url passed to engage.

Do these changes look alright? They worked for me :) I did update both the inline and non-line version, though I only used the inline version. If you have other thoughts on how to approach this, let me know.

@fschwiet
Copy link
Contributor Author

fschwiet commented Apr 1, 2012

another thing.. to support AuthorizationAttribute, I needed to call the following from Application_AuthenticateRequest in Global.asax.cs:

    public static void AuthenticateRequest(HttpRequest httpRequest, HttpContext httpContext)
    {
        HttpCookie authCookie = httpRequest.Cookies[FormsAuthentication.FormsCookieName];
        if (authCookie != null)
        {
            //Extract the forms authentication cookie
            FormsAuthenticationTicket authTicket = FormsAuthentication.Decrypt(authCookie.Value);

            var newUser = new EngagePrincipal(authTicket.Name);
            httpContext.User = newUser;
        }
    }

I am also calling FormsAuthentication.RedirectFromLoginPage() instead of FormsAuthentication.SetAuthCookie() in ProcessLogOn (this does what SetAuthCookie does, and redirects the user). I also set the forms default url in web.config:

<authentication mode="Forms">
  <forms loginUrl="~/Engage/LogOn" defaultUrl="/" timeout="2880" />
</authentication>

Still trying this stuff out for the first time, its working so far.

@fschwiet
Copy link
Contributor Author

fschwiet commented Apr 1, 2012

(this simple IIdentity/IPrincipal implementation is used in the code above: https://gist.github.com/2271479)

troygoode added a commit that referenced this pull request Apr 2, 2012
changes for token_url flexibility
@troygoode troygoode merged commit 10d90a6 into troygoode:master Apr 2, 2012
@troygoode
Copy link
Owner

pulled. thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants