Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

API basic auth

  • Loading branch information...
commit 9ab801b488f840858f5247802d240f401bd8ca59 1 parent aa0518f
@mattyoho mattyoho authored
Showing with 17 additions and 0 deletions.
  1. +17 −0 app/controllers/api_controller.rb
View
17 app/controllers/api_controller.rb
@@ -1,9 +1,26 @@
class ApiController < ActionController::Base
+ before_filter :authenticate
private
+ def authenticate
+ if self.current_user = authenticate_with_http_basic do |username, password|
+ login(username, password)
+ end
+ else
+ request_http_basic_authentication
+ end
+ end
+
def construct_link_header(next_url, last_url)
"<#{next_url}>; rel=\"next\", <#{last_url}>; rel=\"last\""
end
+ def current_user
+ @current_user
+ end
+
+ def current_user=(user)
+ @current_user = user
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.