This repository has been archived by the owner on Jan 9, 2019. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c15e540
commit 1441442
Showing
4 changed files
with
38 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,18 @@ | ||
# Filters added to this controller apply to all controllers in the application. | ||
# Likewise, all the methods added will be available for all controllers. | ||
|
||
class ApplicationController < ActionController::Base | ||
helper :all # include all helpers, all the time | ||
protect_from_forgery # See ActionController::RequestForgeryProtection for details | ||
|
||
# Scrub sensitive parameters from your log | ||
# filter_parameter_logging :password | ||
|
||
before_filter :ssl_required, :unless => :development? | ||
before_filter :authentication_required | ||
|
||
private | ||
|
||
def development? | ||
Rails.env.development? | ||
end | ||
|
||
def ssl_required | ||
unless request.ssl? | ||
render :json => '{"error":"SSL is required."}', :status => :bad_request | ||
end | ||
render(:json => { :error => 'SSL is required.' }, :status => :bad_request) unless request.ssl? | ||
end | ||
|
||
def authentication_required | ||
authenticate_or_request_with_http_basic do |username, password| | ||
username == HIDEABED_API_KEY | ||
end | ||
authenticate_or_request_with_http_basic { |api_key, _| api_key == HIDEABED_API_KEY } | ||
end | ||
|
||
def development? | ||
Rails.env.development? | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,4 @@ class PropertiesController < ApplicationController | |
def index | ||
render :json => { :version => '0.9' } | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters