Forum: Ruby on Rails Authentication for both web & api

Ca073ca5cc615c4ae2107d2626d24498?d=identicon&s=25 renu mehta (sm94582)
on 2013-11-22 01:12
Hello,

I need to develop an application which needs to authenticate user by
verifying login name/password for both web access and api. I need the
same controller to cater to both web and api. I can put the
before_filter for the controller to make sure that user is logged-in and
user_id is in session. But how do I design the controller that if the
request comes as a rest web service request then before filter should
not check session for logged user but should authenticate with
login/password passed as parameters with request and then should go
ahead whichever way the request came to controller.

I would really appreciate any code samples/links to sites which explain
how to do that.

Thanks.
Aa082c8b00a50928e5860dcd70bf2368?d=identicon&s=25 tamouse m. (tamouse_m)
on 2013-11-22 22:00
(Received via mailing list)
On Nov 21, 2013, at 4:12 PM, renu mehta <lists@ruby-forum.com> wrote:

> ahead whichever way the request came to controller.
>
> I would really appreciate any code samples/links to sites which explain
> how to do that.
>
> Thanks.

So I havent personally implemented such a thing, but Ive used such
things. AWS API requests do this thing where you establish a connection
using the two keys (access and secret) and get a token to use for the
rest of your API accesses (Im pretty sure this times out eventually). Im
sure you could work something similar to that using the user/pw?
Ca073ca5cc615c4ae2107d2626d24498?d=identicon&s=25 renu mehta (sm94582)
on 2013-11-22 22:28
Basically, I want to know how to implement different authentication
checks for different request paths - from browser or from api.
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.