fridge 0.4.1 → 0.4.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
  SHA256:
3
- metadata.gz: 73170339e572589b38ca8c30c1bab638b80102caf10ea71572ebdb5168e28397
4
- data.tar.gz: 89ed3cdee4f57bee03d128a155ea3ec8d9b29dfb3343d05b67fe343ac6fc12e7
3
+ metadata.gz: 769896062879cb0dc6c7c69f095a5cedab11beaa0c30cb3e302dfc15eb842343
4
+ data.tar.gz: 657ca035209d5be3fcb78aaa74cc418bf764726622ccc3d90e0cab900ad4cf13
5
5
  SHA512:
6
- metadata.gz: d1b78d332804fe1680c5df49b25fa83e47603281d950705f9c8775e37ad3821971f53670191bb493fc970d9d7d7cf08bbd6a54fd26f9c82402d1a545b49bc964
7
- data.tar.gz: 9d98dead583203b74b41326d7b3b325fb7507ac3a1b2a9fbfbf5bb1120247327a4366f74544efa4f57061f8e340ba918cdd4719c61a5e98a0b992c7a144b8686
6
+ metadata.gz: 1500d9599ef57f700c52c2362086a3c9e0ac1853c2182e72e1f24ffe0583ccdc38bcaca4d7c9e53b792d93b164ae7ac1510af721e7b1359e2e07998da44388b2
7
+ data.tar.gz: e18539fb6ae2d73dac73005348bc78015dc2a708e6d4e3f10b7b430ed8368f16f73d58d876ca6afdfb3dcf41d41b165d4291eac3ef6cb11c03c61ff87574fc72
@@ -0,0 +1 @@
1
+ * @dawenster
@@ -1,6 +1,5 @@
1
1
  sudo: false
2
2
  rvm:
3
- - 2.0.0
4
- - 2.1.0
5
- - 2.2.0
6
- - jruby-9.0.5.0
3
+ - 2.2
4
+ - 2.5
5
+ - 2.6
data/Gemfile CHANGED
@@ -1,7 +1,7 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  gem 'activesupport', '~> 4.0'
4
- gem 'nokogiri', '~> 1.6.0'
4
+ gem 'nokogiri', '~> 1.9.1'
5
5
 
6
6
  # Specify your gem's dependencies in fridge.gemspec
7
7
  gemspec
data/README.md CHANGED
@@ -80,6 +80,4 @@ store_session_cookie(access_token)
80
80
 
81
81
  MIT License, see [LICENSE](LICENSE.md) for details.
82
82
 
83
- Copyright (c) 2014 [Aptible](https://www.aptible.com) and contributors.
84
-
85
- [<img src="https://s.gravatar.com/avatar/f7790b867ae619ae0496460aa28c5861?s=60" style="border-radius: 50%;" alt="@fancyremarker" />](https://github.com/fancyremarker)
83
+ Copyright (c) 2019 [Aptible](https://www.aptible.com) and contributors.
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+
2
3
  lib = File.expand_path('../lib', __FILE__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
5
 
@@ -22,11 +23,11 @@ Gem::Specification.new do |spec|
22
23
  spec.add_dependency 'gem_config'
23
24
  spec.add_dependency 'jwt', '~> 1.5.6'
24
25
 
25
- spec.add_development_dependency 'bundler', '~> 1.5'
26
26
  spec.add_development_dependency 'aptible-tasks'
27
- spec.add_development_dependency 'rake'
27
+ spec.add_development_dependency 'bundler', '~> 1.5'
28
+ spec.add_development_dependency 'pry'
28
29
  spec.add_development_dependency 'rails'
30
+ spec.add_development_dependency 'rake'
29
31
  spec.add_development_dependency 'rspec', '~> 3.0'
30
32
  spec.add_development_dependency 'rspec-rails'
31
- spec.add_development_dependency 'pry'
32
33
  end
@@ -15,7 +15,9 @@ module Fridge
15
15
  has :private_key, classes: [String]
16
16
  has :public_key, classes: [String]
17
17
 
18
- has :signing_algorithm, values: %w(RS512 RS256), default: 'RS512'
18
+ # rubocop:disable Style/PercentLiteralDelimiters
19
+ has :signing_algorithm, values: %w[RS512 RS256], default: 'RS512'
20
+ # rubocop:enable Style/PercentLiteralDelimiters
19
21
 
20
22
  # A validator must raise an exception or return a false value for an
21
23
  # invalid token
@@ -27,6 +27,7 @@ module Fridge
27
27
 
28
28
  def serialize
29
29
  return jwt if jwt
30
+
30
31
  validate_parameters!
31
32
  validate_private_key!
32
33
  encode_and_sign
@@ -40,7 +41,7 @@ module Fridge
40
41
  h.merge!(attributes)
41
42
  h = encode_for_jwt(h)
42
43
  JWT.encode(h, private_key, algorithm)
43
- rescue
44
+ rescue StandardError
44
45
  raise SerializationError, 'Invalid private key or signing algorithm'
45
46
  end
46
47
 
@@ -67,8 +68,9 @@ module Fridge
67
68
 
68
69
  def private_key
69
70
  return unless config.private_key
71
+
70
72
  @private_key ||= OpenSSL::PKey::RSA.new(config.private_key)
71
- rescue
73
+ rescue StandardError
72
74
  nil
73
75
  end
74
76
 
@@ -78,7 +80,7 @@ module Fridge
78
80
  elsif config.public_key
79
81
  @public_key ||= OpenSSL::PKey::RSA.new(config.public_key)
80
82
  end
81
- rescue
83
+ rescue StandardError
82
84
  nil
83
85
  end
84
86
 
@@ -107,6 +109,7 @@ module Fridge
107
109
  def validate_parameters!
108
110
  [:subject, :expires_at].each do |attribute|
109
111
  next if send(attribute)
112
+
110
113
  raise SerializationError, "Missing attribute: #{attribute}"
111
114
  end
112
115
  end
@@ -21,6 +21,7 @@ module Fridge
21
21
 
22
22
  def current_token
23
23
  return unless bearer_token
24
+
24
25
  @current_token ||= AccessToken.new(bearer_token).tap do |token|
25
26
  validate_token!(token)
26
27
  end
@@ -41,10 +42,11 @@ module Fridge
41
42
 
42
43
  def session_token
43
44
  return unless session_cookie
45
+
44
46
  @session_token ||= AccessToken.new(session_cookie).tap do |token|
45
47
  validate_token!(token).downgrade
46
48
  end
47
- rescue
49
+ rescue StandardError
48
50
  clear_session_cookie
49
51
  end
50
52
 
@@ -52,7 +54,7 @@ module Fridge
52
54
  def validate_token(access_token)
53
55
  validator = Fridge.configuration.validator
54
56
  validator.call(access_token) && access_token
55
- rescue
57
+ rescue StandardError
56
58
  false
57
59
  end
58
60
 
@@ -105,6 +107,7 @@ module Fridge
105
107
 
106
108
  def fetch_shared_cookie(name)
107
109
  return read_shared_cookie(name) if read_shared_cookie(name)
110
+
108
111
  write_shared_cookie(yield)
109
112
  end
110
113
 
@@ -1,3 +1,3 @@
1
1
  module Fridge
2
- VERSION = '0.4.1'.freeze
2
+ VERSION = '0.4.2'.freeze
3
3
  end
@@ -6,6 +6,7 @@ module Rails
6
6
 
7
7
  def routes
8
8
  return @routes if defined?(@routes)
9
+
9
10
  @routes = ActionDispatch::Routing::RouteSet.new
10
11
  @routes.draw do
11
12
  resources :posts
@@ -15,6 +16,6 @@ module Rails
15
16
  end
16
17
 
17
18
  def self.application
18
- @app ||= App.new
19
+ @application ||= App.new
19
20
  end
20
21
  end
@@ -23,7 +23,8 @@ describe Fridge::AccessToken do
23
23
  end
24
24
 
25
25
  it 'should raise an error on an invalid JWT' do
26
- expect { described_class.new('foobar') }.to raise_error
26
+ expect { described_class.new('foobar') }
27
+ .to raise_error Fridge::InvalidToken
27
28
  end
28
29
 
29
30
  it 'should raise an error on an incorrectly signed JWT' do
@@ -93,7 +94,7 @@ describe Fridge::AccessToken do
93
94
 
94
95
  it 'should represent :exp in seconds since the epoch' do
95
96
  hash, = JWT.decode(subject.serialize, public_key)
96
- expect(hash['exp']).to be_a Fixnum
97
+ expect(hash['exp']).to be_a Integer
97
98
  end
98
99
 
99
100
  it 'should be deterministic' do
@@ -152,7 +152,8 @@ describe Fridge::RailsHelpers do
152
152
  describe '#validate_token' do
153
153
  it 'should raise an exception if the token is invalid' do
154
154
  Fridge.configuration.validator = ->(_) { false }
155
- expect { controller.validate_token!(access_token) }.to raise_error
155
+ expect { controller.validate_token!(access_token) }
156
+ .to raise_error Fridge::InvalidToken
156
157
  end
157
158
 
158
159
  it 'should return the token if valid' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fridge
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Frank Macreery
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-21 00:00:00.000000000 Z
11
+ date: 2020-07-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gem_config
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: 1.5.6
41
+ - !ruby/object:Gem::Dependency
42
+ name: aptible-tasks
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: bundler
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -53,7 +67,7 @@ dependencies:
53
67
  - !ruby/object:Gem::Version
54
68
  version: '1.5'
55
69
  - !ruby/object:Gem::Dependency
56
- name: aptible-tasks
70
+ name: pry
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
73
  - - ">="
@@ -67,7 +81,7 @@ dependencies:
67
81
  - !ruby/object:Gem::Version
68
82
  version: '0'
69
83
  - !ruby/object:Gem::Dependency
70
- name: rake
84
+ name: rails
71
85
  requirement: !ruby/object:Gem::Requirement
72
86
  requirements:
73
87
  - - ">="
@@ -81,7 +95,7 @@ dependencies:
81
95
  - !ruby/object:Gem::Version
82
96
  version: '0'
83
97
  - !ruby/object:Gem::Dependency
84
- name: rails
98
+ name: rake
85
99
  requirement: !ruby/object:Gem::Requirement
86
100
  requirements:
87
101
  - - ">="
@@ -122,20 +136,6 @@ dependencies:
122
136
  - - ">="
123
137
  - !ruby/object:Gem::Version
124
138
  version: '0'
125
- - !ruby/object:Gem::Dependency
126
- name: pry
127
- requirement: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - ">="
130
- - !ruby/object:Gem::Version
131
- version: '0'
132
- type: :development
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - ">="
137
- - !ruby/object:Gem::Version
138
- version: '0'
139
139
  description: Token validation for distributed resource servers
140
140
  email:
141
141
  - frank@macreery.com
@@ -143,6 +143,7 @@ executables: []
143
143
  extensions: []
144
144
  extra_rdoc_files: []
145
145
  files:
146
+ - ".github/CODEOWNERS"
146
147
  - ".gitignore"
147
148
  - ".rspec"
148
149
  - ".travis.yml"
@@ -167,7 +168,7 @@ homepage: https://github.com/aptible/fridge
167
168
  licenses:
168
169
  - MIT
169
170
  metadata: {}
170
- post_install_message:
171
+ post_install_message:
171
172
  rdoc_options: []
172
173
  require_paths:
173
174
  - lib
@@ -182,9 +183,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
182
183
  - !ruby/object:Gem::Version
183
184
  version: '0'
184
185
  requirements: []
185
- rubyforge_project:
186
- rubygems_version: 2.7.6
187
- signing_key:
186
+ rubygems_version: 3.0.3
187
+ signing_key:
188
188
  specification_version: 4
189
189
  summary: Token validation for distributed resource servers
190
190
  test_files: