identity-gateway 1.0.2 → 1.1.2

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: 0e721ce9972b4cb76a467778243966b45dc7014b
4
- data.tar.gz: d1480c5dd6be0551e10b7706619b63d449a70435
3
+ metadata.gz: 07d02983cb60514775eb44ba094f7098641e7d34
4
+ data.tar.gz: 643f687fd8b54a1bb1614d4bcc5608c4edae5670
5
5
  SHA512:
6
- metadata.gz: 00897969823bcbd28e154cc6323f4c3593146d25d1fd11d72d43d56043ec44c612c8744bfdf9ed92f9b462e9cd5ed9c490ec7ed32557c1f1db2fdabcddd07592
7
- data.tar.gz: 4767d438baffbcc32016bd3ce7023ac1154c9addab9fbbb56e3f97a3b975d573bdfe3f1b224265a69ff675fa8e09328783b07e0905014f675142c6ceae3ed775
6
+ metadata.gz: 5df55696048b11a7e63280ab189284294174bba901c7a603a5fa89591095b6767d1aedcfd8fff87b82e2c3b55100afd41ad0bb92e6956a72a149f4f944fd2073
7
+ data.tar.gz: 1530bd59609dddca227deac63ec9bc4134ec998ddcc262c8beee6e96027ef13227457a81a1a1712ff0309c805a6c735a2252d27d0b2cfec3d94609429fd2baf3
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.2.4
data/README.md CHANGED
@@ -1,8 +1,7 @@
1
1
  # Identity::Gateway
2
2
 
3
- [![Gem Version][GV img]][Gem Version]
4
- [Gem Version]: https://rubygems.org/gems/identity-gateway
5
- [GV img]: https://img.shields.io/gem/v/identity-gateway.svg
3
+ [![Gem Version](https://img.shields.io/gem/v/identity-gateway.svg)](https://rubygems.org/gems/identity-gateway)
4
+ [![CircleCI](https://circleci.com/gh/wamland-team/identity-gateway.svg?style=shield&circle-token=b03fdcc75674d173f58a296cb1a3b2162b6828dc)](https://circleci.com/gh/wamland-team/identity-gateway)
6
5
 
7
6
  Identity's gateway provider for Ruby and Rails applications. Act as a man in the middle between backend services and Identity.
8
7
 
@@ -88,10 +87,10 @@ class ApplicationController < ActionController::Base
88
87
  end
89
88
  ```
90
89
 
91
- Alternatively, you can globally handle Identity::Gateway::Unauthorized's by having rails handle them as a 403 error and serving a 403 error page. Add the following to application.rb:
90
+ Alternatively, you can globally handle Identity::Gateway::Unauthorized's by having rails handle them as a 401 error and serving a 401 error page. Add the following to application.rb:
92
91
 
93
92
  ```ruby
94
- config.action_dispatch.rescue_responses['Identity::Gateway::Unauthorized'] = :forbidden
93
+ config.action_dispatch.rescue_responses['Identity::Gateway::Unauthorized'] = :unauthorized
95
94
  ```
96
95
 
97
96
  ## Configuration
data/circle.yml ADDED
@@ -0,0 +1,11 @@
1
+ machine:
2
+ ruby:
3
+ version: 2.2.4
4
+
5
+ ## Customize dependencies
6
+ dependencies:
7
+ pre:
8
+ - sudo apt-get update
9
+ override:
10
+ - bundle install: # note ':' here
11
+ timeout: 180 # fail if command has no output for 3 minutes
@@ -21,10 +21,10 @@ Gem::Specification.new do |spec|
21
21
  f.match(%r{^(test|spec|features)/})
22
22
  end
23
23
 
24
- spec.required_ruby_version = '>= 1.9.3'
24
+ spec.required_ruby_version = '>= 2.2.2'
25
25
 
26
26
  spec.add_dependency 'httparty', '~> 0.13'
27
- spec.add_development_dependency 'bundler', '~> 1.14.6', '>= 1.14.6'
27
+ spec.add_development_dependency 'bundler'
28
28
  spec.add_development_dependency 'rake', '~> 11.3'
29
29
  spec.add_development_dependency 'rspec', '~> 3.5'
30
30
  spec.add_development_dependency 'rubocop', '~> 0.47.1'
@@ -41,6 +41,18 @@ module Identity
41
41
  @subject
42
42
  end
43
43
 
44
+ # Revoke access token.
45
+ #
46
+ # ==== Returns
47
+ # * <tt>HTTParty::Response</tt>.
48
+ def revoke_access!
49
+ self.class.post(
50
+ "#{@settings.provider_url}/oauth/revoke",
51
+ body: { token: request_token }.to_json,
52
+ headers: api_headers
53
+ )
54
+ end
55
+
44
56
  protected
45
57
 
46
58
  # Try to authorize token against provider.
@@ -53,7 +65,7 @@ module Identity
53
65
  headers: api_headers
54
66
  )
55
67
 
56
- raise Unauthorized if @response.code == 401
68
+ raise Unauthorized if invalid_response?(@response)
57
69
  @subject = @model.from_oauth_provider(@response.parsed_response)
58
70
  end
59
71
 
@@ -62,7 +74,7 @@ module Identity
62
74
  # ==== Returns
63
75
  # * <tt>String</tt> - token.
64
76
  def request_token
65
- (@request.headers['Authorization'] || '').gsub('Bearer ', '')
77
+ (@request.headers['Authorization'] || @request.params['access_token'] || '').gsub('Bearer ', '')
66
78
  end
67
79
 
68
80
  # Required headers.
@@ -76,6 +88,17 @@ module Identity
76
88
  'Authorization' => @request.headers['Authorization'] || ''
77
89
  }
78
90
  end
91
+
92
+ # Invalid Response.
93
+ #
94
+ # ==== Returns
95
+ # * <tt>Boolean</tt> - True if is an invalid response.
96
+ def invalid_response?(response)
97
+ parsed_response = response.parsed_response
98
+ return true if response.code == 401 || parsed_response.nil? || parsed_response['id'].nil?
99
+
100
+ false
101
+ end
79
102
  end
80
103
  end
81
104
  end
@@ -1,5 +1,5 @@
1
1
  module Identity
2
2
  module Gateway
3
- VERSION = '1.0.2'.freeze
3
+ VERSION = '1.1.2'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: identity-gateway
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Loic Kartono
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-03-13 00:00:00.000000000 Z
11
+ date: 2022-03-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -28,22 +28,16 @@ dependencies:
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: 1.14.6
34
31
  - - ">="
35
32
  - !ruby/object:Gem::Version
36
- version: 1.14.6
33
+ version: '0'
37
34
  type: :development
38
35
  prerelease: false
39
36
  version_requirements: !ruby/object:Gem::Requirement
40
37
  requirements:
41
- - - "~>"
42
- - !ruby/object:Gem::Version
43
- version: 1.14.6
44
38
  - - ">="
45
39
  - !ruby/object:Gem::Version
46
- version: 1.14.6
40
+ version: '0'
47
41
  - !ruby/object:Gem::Dependency
48
42
  name: rake
49
43
  requirement: !ruby/object:Gem::Requirement
@@ -96,6 +90,7 @@ files:
96
90
  - ".gitignore"
97
91
  - ".rspec"
98
92
  - ".rubocop.yml"
93
+ - ".ruby-version"
99
94
  - ".travis.yml"
100
95
  - Gemfile
101
96
  - LICENSE.txt
@@ -103,6 +98,7 @@ files:
103
98
  - Rakefile
104
99
  - bin/console
105
100
  - bin/setup
101
+ - circle.yml
106
102
  - identity-gateway.gemspec
107
103
  - lib/identity/gateway.rb
108
104
  - lib/identity/gateway/configuration.rb
@@ -120,7 +116,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
120
116
  requirements:
121
117
  - - ">="
122
118
  - !ruby/object:Gem::Version
123
- version: 1.9.3
119
+ version: 2.2.2
124
120
  required_rubygems_version: !ruby/object:Gem::Requirement
125
121
  requirements:
126
122
  - - ">="