Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

closes #1

  • Loading branch information...
commit 046b015662c60b757986a66032fa0b6a46cc5655 1 parent 4656143
Dave Kiger authored
View
4 lib/restful_api_authentication.rb
@@ -45,8 +45,8 @@ def authenticated?
# client must have is_master flag set to true to pass authentication
# returns a 401 not authorized if the authentication headers are missing or invalid
def authenticated_master?
- checker = RestfulApiAuthentication::Checker.new(request.headers, request.fullpath, :require_master => true)
- if checker.authorized?
+ checker = RestfulApiAuthentication::Checker.new(request.headers, request.fullpath)
+ if checker.authorized?({:require_master => true})
return true
else
respond_with(["not authorized"], :status => 401, :location => nil)
View
2  lib/restful_api_authentication/version.rb
@@ -22,5 +22,5 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
module RestfulApiAuthentication
- VERSION = "0.1.0"
+ VERSION = "0.1.1"
end
View
2  test/dummy/Gemfile
@@ -5,7 +5,7 @@ gem 'jquery-rails'
gem 'uuid', '2.3.5'
gem 'chronic', '0.6.7'
gem 'sqlite3'
-gem 'restful_api_authentication', '0.1.0', :path => '/Users/dkiger/git_repos/restful_api_authentication'
+gem 'restful_api_authentication', '0.1.1', :path => '/Users/dkiger/git_repos/restful_api_authentication'
group :assets do
gem 'sass-rails', '~> 3.2.3'
View
6 test/dummy/app/controllers/help_controller.rb
@@ -1,5 +1,11 @@
class HelpController < ApplicationController
+ skip_before_filter :authenticated?, :only => [:master_authentication]
+ before_filter :authenticated_master?, :only => [:master_authentication]
def authentication
respond_with(["authorized"], :status => 200, :location => nil)
end
+
+ def master_authentication
+ respond_with(["authorized"], :status => 200, :location => nil)
+ end
end
View
1  test/dummy/config/routes.rb
@@ -2,6 +2,7 @@
resources :help, :only => [] do
collection do
get "authentication"
+ get "master_authentication"
end
end
end
View
23 test/dummy/features/api/master_authentication.feature
@@ -0,0 +1,23 @@
+Feature: Authentication Testing
+ The web service provides a way to test authentication.
+
+ Scenario: When I post a request as JSON with valid authentication credentials, then the app will say I am authorized.
+ Given I am authenticated
+ Given I have master permissions
+ When I perform a GET to "/help/master_authentication" as JSON
+ Then the HTTP status code should be "200"
+ And the response at index 0 of the JSON response data should be "authorized"
+
+ Scenario: When I post a request as XML with valid authentication credentials, then the app will say I am authorized.
+ Given I am authenticated
+ Given I have master permissions
+ When I perform a GET to "/help/master_authentication" as XML
+ Then the HTTP status code should be "200"
+ And the response at index 0 of the XML response data should be "authorized"
+
+ Scenario: When I post a request as HTTP with valid authentication credentials, then the app will say I am authorized.
+ Given I am authenticated
+ Given I have master permissions
+ When I perform a GET to "/help/master_authentication" as HTTP
+ Then the HTTP status code should be "200"
+ And the response at index 0 of the JSON response data should be "authorized"
Please sign in to comment.
Something went wrong with that request. Please try again.