Advertisement
Guest User

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

a guest
Feb 26th, 2012
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement