restful_api_authentication 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/CHANGELOG.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  ## Version 0.2.0
4
4
 
5
- * Added verbose error messaging; if this is enabled in the YML config file, then the response to an authentication failure will be more descriptive as to why the authentication failed.
5
+ * Added verbose error messaging; if this is enabled in the YML config file, then the response to an authentication failure will be more descriptive as to why the authentication failed. To enable, add `verbose_errors: true` to the `config/restful_api_authentication.yml`.
6
6
 
7
7
  ## Version 0.1.2
8
8
 
data/README.md CHANGED
@@ -100,6 +100,14 @@ puts result.inspect
100
100
 
101
101
  In the `config/restful_api_authentication.yml` file you will find several things that you can change. The defaults are usually fine for most cases.
102
102
 
103
+ #### Verbose Error Messages (>= 0.2.0)
104
+
105
+ By default, the standard response to any authentication error is "not authorized". However, more meaningful explanations of why authentication is failing can be sent by adding the following to the `config/restful_api_authentication.yml` file:
106
+
107
+ ```
108
+ verbose_errors: true
109
+ ```
110
+
103
111
  ### Requiring Authentication
104
112
 
105
113
  To require authentication for a specific resource (controller) of your RESTful web service, add this at the top of your controller just under where you open the controller class:
@@ -30,12 +30,17 @@ module RestfulApiAuthentication
30
30
  RestfulApiAuthentication::Checker.header_api_key = 'x-api-key'
31
31
  RestfulApiAuthentication::Checker.verbose_errors = false
32
32
  if File.exists? Rails.root.join('config', 'restful_api_authentication.yml')
33
- config_data = YAML::load_file(Rails.root.join('config', 'restful_api_authentication.yml'))[Rails.env]
34
- RestfulApiAuthentication::Checker.time_window ||= config_data['request_window']
35
- RestfulApiAuthentication::Checker.header_timestamp ||= config_data['header_names']['timestamp']
36
- RestfulApiAuthentication::Checker.header_signature ||= config_data['header_names']['signature']
37
- RestfulApiAuthentication::Checker.header_api_key ||= config_data['header_names']['api_key']
38
- RestfulApiAuthentication::Checker.verbose_errors ||= config_data['verbose_errors']
33
+ begin
34
+ config_data = YAML::load_file(Rails.root.join('config', 'restful_api_authentication.yml'))[Rails.env]
35
+ RestfulApiAuthentication::Checker.time_window = config_data['request_window'].to_i unless config_data['request_window'].nil?
36
+ RestfulApiAuthentication::Checker.header_timestamp = config_data['header_names']['timestamp'] unless config_data['header_names'].nil? or config_data['header_names']['timestamp'].nil?
37
+ RestfulApiAuthentication::Checker.header_signature = config_data['header_names']['signature'] unless config_data['header_names'].nil? or config_data['header_names']['signature'].nil?
38
+ RestfulApiAuthentication::Checker.header_api_key = config_data['header_names']['api_key'] unless config_data['header_names'].nil? or config_data['header_names']['api_key'].nil?
39
+ RestfulApiAuthentication::Checker.verbose_errors = config_data['verbose_errors'] unless config_data['verbose_errors'].nil?
40
+ rescue Exception => e
41
+ # do nothing here -- we already have set the defaults
42
+ Rails.logger.debug e.message
43
+ end
39
44
  end
40
45
  end
41
46
  end
@@ -22,5 +22,5 @@
22
22
  # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
23
 
24
24
  module RestfulApiAuthentication
25
- VERSION = "0.2.0"
25
+ VERSION = "0.2.1"
26
26
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: restful_api_authentication
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-25 00:00:00.000000000 Z
12
+ date: 2012-06-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
16
- requirement: &70141551581760 !ruby/object:Gem::Requirement
16
+ requirement: &70131007101400 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 3.2.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70141551581760
24
+ version_requirements: *70131007101400
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: uuid
27
- requirement: &70141551581260 !ruby/object:Gem::Requirement
27
+ requirement: &70131007100900 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 2.3.5
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70141551581260
35
+ version_requirements: *70131007100900
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: chronic
38
- requirement: &70141551580780 !ruby/object:Gem::Requirement
38
+ requirement: &70131007100420 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: 0.6.7
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70141551580780
46
+ version_requirements: *70131007100420
47
47
  description: A gem which implements a standard api_key / secret authentication system
48
48
  for your Ruby on Rails RESTful web services.
49
49
  email: