Now, we will learn about authentication using RhoSync. We have a login page in Rhodes application, whatever username and password we enter they are accessible inside the authentication method in application.rb
file of the RhoSync application. The RhoSync application code includes a file at the root called application.rb
that contains an authenticate
hook. This method is called when a device first connects to the RhoSync application and provides the username/password:
class Application < Rhosync::Base class << self def authenticate(username,password,session) true # do some interesting authentication here... end def initializer(path) super end def store_blob(object,field_name,blob) super #=> returns blob[:tempfile] end end end Application.initializer(ROOT_PATH)
If your backend web service requires authentication, simply add code to the authenticate method and return true if authentication was successful or false to deny access...