Authentication for both web & api

25 views
Skip to first unread message

renu mehta

unread,
Nov 21, 2013, 7:12:57 PM11/21/13
to rubyonra...@googlegroups.com
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.

--
Posted via http://www.ruby-forum.com/.

Tamara Temple

unread,
Nov 22, 2013, 3:58:28 PM11/22/13
to rubyonra...@googlegroups.com
So I haven’t personally implemented such a thing, but I’ve 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 (I’m pretty sure this times out eventually). I’m sure you could work something similar to that using the user/pw?

renu mehta

unread,
Nov 22, 2013, 4:28:26 PM11/22/13
to rubyonra...@googlegroups.com
Basically, I want to know how to implement different authentication
checks for different request paths - from browser or from api.
Reply all
Reply to author
Forward
0 new messages