Thursday, July 9, 2009

Password protect remote resource

This came up the other day, and I wasn't sure how to handle it. The solution is simple, but not obvious. I'm trying to put as much code as possible in my posts, but this one is really more of a conceptual issue. The code is way simple.

Problem:

You have a link that points to a remote location, and you need to dynamically set params, which depend on login info.

Non-solution:

If the user is not logged in, send the user to the login page and then back to the page with the link, after they've logged in. This works, but asks to much of the user. They have to click the same link twice.

Solution:

What you really want is a way to wrap the remote resource with an action of your own. That index should do two things: redirect to the remote resource, and have a before filter that authorizes the user.

No comments:

Post a Comment