SHARE
TWEET

Is this a reasonable approach for HTTP BASIC authentication with an API key

a guest Feb 26th, 2012 27 Never
  1. def http_basic_authentication
  2.     if request.format == Mime::XML
  3.       authenticate_or_request_with_http_basic do |username, api_key|
  4.         self.current_user = User.find(:first, :from => 'users, accounts', :conditions => ["accounts.id = users.account_id AND accounts.api_key = ?", api_key])
  5.       end
  6.     end
  7.   end
  8.        
  9. self.current_user = Account.find_by_api_key(api_key).user
RAW Paste Data
Top