Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mobile API Authentication with Rails

I'm building a mobile API server for an APP. My server needs to supports users and authentication. for the last 2 days i've been searching for a good gem/ best practices of doing such task and i've failed to found.

I've seen tweaks around devise or self implementation of authentication tokens but yet to discover a full solution for such a trivial task.

http://lucatironi.github.io/tutorial/2012/10/15/ruby_rails_android_app_authentication_devise_tutorial_part_one/

https://github.com/plataformatec/devise/issues/2739

like image 858
Or Ron Avatar asked Mar 18 '23 20:03

Or Ron


1 Answers

Check out the Arcadex gem https://github.com/cleor41/ArcadeX.

It's a rails engine that creates a token model. You put the gem's function inside your application controller and it grabs the token from the request headers or parameters and returns the user associated with the token or nil. Nil means the user could not be found/the token is nonexistent. The only setup is to create a token when a user is created and you want to return this token after registering or signing up and destroy it after signing out. An example use case can be found on that github. All of the functions you need for this are completed. The github will tell you where to place them.

I hope it helps out!

like image 134
CleoR Avatar answered Mar 23 '23 23:03

CleoR