Pastebin launched a little side project called HostCabi.net, check it out ;-)Don't like ads? PRO users don't see any ads ;-)
Guest

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

By: a guest on Feb 26th, 2012  |  syntax: None  |  size: 0.37 KB  |  hits: 26  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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