api_guard 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5fb06d2b7085c3eb3819a89610602c556435440a
4
- data.tar.gz: 3f78360c4859b5d18aedcf9031526c4c7b13d01a
3
+ metadata.gz: 6163657dcf0320abbfc8e4bde50f0e991ec68a6f
4
+ data.tar.gz: 33fc35d38fd11c550108008c9878bf5461b2e089
5
5
  SHA512:
6
- metadata.gz: b6531b78c3c2a6c1d90a1ed2a12644f16294eaeb949b3a2932909d88cd3dfa46bff3dff2afdc3c358422078ed3ccd47eefd164773ec7a11e5308a97ec5979495
7
- data.tar.gz: 4a2cc065e85e1fc78afe832771dfb1df2eb49ad54afa1b0b69b00edd5a40f1b3ed64b28063ce068babe9f1d0118b6a9dcdfafea25b51c64e71e796d7f81c4c29
6
+ metadata.gz: f8cc3aa3863bd6f2e7ff3e54004c4af9ab7c053d21554af98f4f38d75494833b541472b8ed3327540f608b5efc70cbd4bfa84e641a90e7a58ab80a001e73f9cc
7
+ data.tar.gz: 7cc0936550701a8fcfccf9953d6cb30d4d03269d7478a3f62ea4bb6774696ac97acdad59cfc02a740a37fad7a58c4f8687586ce00e185b4d6f65257d54e7f775
@@ -18,11 +18,10 @@ module ApiGuard
18
18
  def authenticate_and_set_resource(resource_name)
19
19
  @resource_name = resource_name
20
20
 
21
- authenticate_or_request_with_http_token do |token, _|
22
- @token = token
23
- authenticate_token
24
- true # Return true to handle 'Invalid access token' request separately
25
- end
21
+ @token = request.headers['Authorization']&.split('Bearer ')&.last
22
+ return render_error(401, message: 'Access token is missing in the request') unless @token
23
+
24
+ authenticate_token
26
25
 
27
26
  # Render error response only if no resource found and no previous render happened
28
27
  render_error(401, message: 'Invalid access token') if !current_resource && !performed?
@@ -34,12 +33,6 @@ module ApiGuard
34
33
  end
35
34
  end
36
35
 
37
- # Override to send JSON response instead of plain HTML
38
- # if 'Authorization' header is empty or value of the header is invalid
39
- def request_http_token_authentication(realm = 'Application', _message = nil)
40
- render_error(401, message: 'Access token is missing in the request')
41
- end
42
-
43
36
  # Decode the JWT token
44
37
  # and don't verify token expiry for refresh token API request
45
38
  def decode_token
@@ -1,3 +1,3 @@
1
1
  module ApiGuard
2
- VERSION = '0.1.2'
2
+ VERSION = '0.1.3'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: api_guard
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gokul Murali
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-03-23 00:00:00.000000000 Z
11
+ date: 2019-03-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jwt