Basic authentication for rails APIs

I am developing a simple api that will be used by iphone. Is there a simple authentication bug (with token authentication or api key) on the rails that I can use via http (No https). Some things, such as Devise with token_authentication function, are included.

+4
source share
1 answer

you can simply add HTTP basic auth support by adding the following to the application controller

before_filter :http_basic_authenticate def http_basic_authenticate authenticate_or_request_with_http_basic do |username, password| username == "1username" && password == "password1" end end 

then try

 curl http://yourdomain.com => HTTP Basic: Access denied. curl --user 1username:password1 http://yourdomain.com => result ..... 
+7
source

Source: https://habr.com/ru/post/1414861/


All Articles