pansophy_authenticator 0.2.0 → 0.3.0

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: 7af7e60f259d600f0f144d92093cf6e72281e89f
4
- data.tar.gz: 19fcf4ca69a64465d75e2a963744ccff2d3738a3
3
+ metadata.gz: 1a3e9c1d43153905040277676f4ce886c9f80eff
4
+ data.tar.gz: 6dff940369d0b5c392834a841a3dfaeff29ddb08
5
5
  SHA512:
6
- metadata.gz: 1aa802262c4c530e651a9a3c32b5237827181c54c550802f3087f902828ad232ac5c0ea8efb0f967d04e6c09e315b38409289b720c383f5877b483cbbf236537
7
- data.tar.gz: 617e24f95dec81945c00dd7363351b1c557fcf5a8827e6dd54550699d0c5ed7244f15de7340848e345a525998414765e4ea41c54dcfc65e591e8751a5ee5cf97
6
+ metadata.gz: bd5fd51d19c1b774741a261307df5a83949201a2ed9c86e9337eff4f949b64af42602b7455a7a9d7189ad846a40e8947a29996a81e1c88ab4bc734fe32d01cd7
7
+ data.tar.gz: a636e340701b60f323deca0ee8abcb84b02b404c230ce83ab7773f48dc5623999a8b2105006d37cc623d5bfc000863923c5b8d6c6a41816f2d85a8283a1cea25
data/.rubocop.yml CHANGED
@@ -9,3 +9,6 @@ Style/BlockDelimiters:
9
9
 
10
10
  Style/TrivialAccessors:
11
11
  AllowPredicates: true
12
+
13
+ Style/SignalException:
14
+ EnforcedStyle: semantic
data/.travis.yml CHANGED
@@ -8,4 +8,4 @@ notifications:
8
8
  email:
9
9
  - support@travellink.com.au
10
10
  flowdock:
11
- secure: X54gP0PjRDh289791y3jqYryuiWX6RNTNvxpzMVU0l3sw4JwxgjlfGG+VCYtje06D9rd3KJeostko1dqpP6RFiZCcOgd/zjsexP0JokD1e42hM2FTFCu7cMAn+VeWSN42NWTFp+8YIpcKbITiywkIREzHjXXW6jthh6aFEoMUD7u4qUy71iL2gGLlOwIL8IfUAljn1bDAr5w5yFSQvhywldG8QDvHav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VMVJxRIaUZgzim47I3r7nHKpA9fGh7ipM/pqMBTEnWC64sqQYZTWbFYQ18OyaRtqtdN3Ou3xDY+obPY=
data/CHANGELOG.md CHANGED
@@ -1,6 +1,19 @@
1
+ ## 0.3.0 (2016-02-12)
2
+
3
+ Adds:
4
+
5
+ - Configuration validation
6
+
7
+ ## 0.2.1 (2016-02-05)
8
+
9
+ Fixes:
10
+
11
+ - Security fix: be agnostic on cause of validation failure
12
+ - Don't raise errors when checking validation via #valid?
13
+
1
14
  ## 0.2.0 (2016-02-02)
2
15
 
3
- Features:
16
+ Adds:
4
17
 
5
18
  - caching via cache store
6
19
 
@@ -7,3 +7,4 @@ require 'pansophy_authenticator/configuration/configurator'
7
7
  require 'pansophy_authenticator/configuration/from_file'
8
8
  require 'pansophy_authenticator/configuration/from_env'
9
9
  require 'pansophy_authenticator/configuration/instance'
10
+ require 'pansophy_authenticator/configuration/verification'
@@ -1,9 +1,11 @@
1
1
  require 'anima'
2
+ require 'memoizable'
2
3
 
3
4
  module PansophyAuthenticator
4
5
  module Configuration
5
6
  class Instance
6
7
  include Anima.new :local, :bucket_name, :file_path, :application, :cache_store
8
+ include Memoizable
7
9
 
8
10
  def local?
9
11
  @local
@@ -12,6 +14,21 @@ module PansophyAuthenticator
12
14
  def remote?
13
15
  !local?
14
16
  end
17
+
18
+ def valid?
19
+ verification.valid?
20
+ end
21
+
22
+ def errors
23
+ verification.errors
24
+ end
25
+
26
+ private
27
+
28
+ def verification
29
+ Verification::Verify.new(self).call
30
+ end
31
+ memoize :verification
15
32
  end
16
33
  end
17
34
  end
@@ -0,0 +1,12 @@
1
+ module PansophyAuthenticator
2
+ module Configuration
3
+ module Verification
4
+ end
5
+ end
6
+ end
7
+
8
+ require 'pansophy_authenticator/configuration/verification/result'
9
+ require 'pansophy_authenticator/configuration/verification/common'
10
+ require 'pansophy_authenticator/configuration/verification/local'
11
+ require 'pansophy_authenticator/configuration/verification/remote'
12
+ require 'pansophy_authenticator/configuration/verification/verify'
@@ -0,0 +1,16 @@
1
+ module PansophyAuthenticator
2
+ module Configuration
3
+ module Verification
4
+ class Common
5
+ def initialize(configuration)
6
+ @configuration = configuration
7
+ end
8
+
9
+ def verify
10
+ return Result.new 'Application is not defined' if @configuration.application.nil?
11
+ Result.new
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,35 @@
1
+ module PansophyAuthenticator
2
+ module Configuration
3
+ module Verification
4
+ class Local
5
+ def initialize(configuration)
6
+ @configuration = configuration
7
+ end
8
+
9
+ def verify
10
+ Result.new errors
11
+ end
12
+
13
+ private
14
+
15
+ def errors
16
+ return ['File path is not defined'] unless file_path?
17
+ return ["#{file_path} does not exist"] unless file_exist?
18
+ []
19
+ end
20
+
21
+ def file_path?
22
+ !file_path.nil?
23
+ end
24
+
25
+ def file_exist?
26
+ File.exist? file_path
27
+ end
28
+
29
+ def file_path
30
+ @configuration.file_path
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,19 @@
1
+ module PansophyAuthenticator
2
+ module Configuration
3
+ module Verification
4
+ class Remote
5
+ def initialize(configuration)
6
+ @configuration = configuration
7
+ @result = Result.new
8
+ end
9
+
10
+ def verify
11
+ errors = []
12
+ errors << 'Bucket name is not defined' if @configuration.bucket_name.nil?
13
+ errors << 'File path is not defined' if @configuration.file_path.nil?
14
+ Result.new errors
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,25 @@
1
+ module PansophyAuthenticator
2
+ module Configuration
3
+ module Verification
4
+ class Result
5
+ include Adamantium
6
+
7
+ attr_reader :errors
8
+
9
+ def initialize(errors = [])
10
+ @errors = Array(errors)
11
+ end
12
+
13
+ def valid?
14
+ @errors.empty?
15
+ end
16
+
17
+ def +(other)
18
+ transform do
19
+ @errors += other.errors
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,29 @@
1
+ module PansophyAuthenticator
2
+ module Configuration
3
+ module Verification
4
+ class Verify
5
+ def initialize(configuration)
6
+ @configuration = configuration
7
+ end
8
+
9
+ def call
10
+ verifiers.map { |verifier| verifier.new(@configuration).verify }.reduce(&:+)
11
+ end
12
+
13
+ private
14
+
15
+ def verifiers
16
+ [Common, specific_verifier]
17
+ end
18
+
19
+ def specific_verifier
20
+ if @configuration.local?
21
+ Local
22
+ else
23
+ Remote
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -6,16 +6,21 @@ module PansophyAuthenticator
6
6
  end
7
7
 
8
8
  def validate!(given_key)
9
- fail Error, "Invalid key for #{@application}" unless valid?(given_key)
9
+ fail Error, 'Invalid application or key' unless valid?(given_key)
10
10
  end
11
11
 
12
12
  def valid?(given_key)
13
+ return false unless valid_application?
13
14
  given_key == key
14
15
  end
15
16
 
16
17
  def key
17
- fail Error, "#{@application} is not defined" unless @keys.key?(@application)
18
+ fail Error, "#{@application} is not defined" unless valid_application?
18
19
  @keys.fetch(@application)
19
20
  end
21
+
22
+ def valid_application?
23
+ @keys.key?(@application)
24
+ end
20
25
  end
21
26
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module PansophyAuthenticator
3
- VERSION = '0.2.0'.freeze
3
+ VERSION = '0.3.0'.freeze
4
4
  end
@@ -28,6 +28,7 @@ Gem::Specification.new do |spec|
28
28
 
29
29
  spec.add_dependency 'memoize', '~> 1.3'
30
30
  spec.add_dependency 'anima', '~> 0.3'
31
+ spec.add_dependency 'adamantium', '~> 0.2'
31
32
  spec.add_dependency 'pansophy', '~> 0.3'
32
33
  spec.add_dependency 'yamload', '~> 0.2'
33
34
 
@@ -38,6 +39,6 @@ Gem::Specification.new do |spec|
38
39
  spec.add_development_dependency 'simplecov', '~> 0.11'
39
40
  spec.add_development_dependency 'simplecov-rcov', '~> 0.2'
40
41
  spec.add_development_dependency 'coveralls', '~> 0.8'
41
- spec.add_development_dependency 'rubocop', '~> 0.36'
42
+ spec.add_development_dependency 'rubocop', '~> 0.37'
42
43
  spec.add_development_dependency 'travis', '~> 1.8'
43
44
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pansophy_authenticator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alessandro Berardi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-02-02 00:00:00.000000000 Z
11
+ date: 2016-02-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: memoize
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: adamantium
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0.2'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0.2'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: pansophy
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -170,14 +184,14 @@ dependencies:
170
184
  requirements:
171
185
  - - "~>"
172
186
  - !ruby/object:Gem::Version
173
- version: '0.36'
187
+ version: '0.37'
174
188
  type: :development
175
189
  prerelease: false
176
190
  version_requirements: !ruby/object:Gem::Requirement
177
191
  requirements:
178
192
  - - "~>"
179
193
  - !ruby/object:Gem::Version
180
- version: '0.36'
194
+ version: '0.37'
181
195
  - !ruby/object:Gem::Dependency
182
196
  name: travis
183
197
  requirement: !ruby/object:Gem::Requirement
@@ -224,6 +238,12 @@ files:
224
238
  - lib/pansophy_authenticator/configuration/from_env.rb
225
239
  - lib/pansophy_authenticator/configuration/from_file.rb
226
240
  - lib/pansophy_authenticator/configuration/instance.rb
241
+ - lib/pansophy_authenticator/configuration/verification.rb
242
+ - lib/pansophy_authenticator/configuration/verification/common.rb
243
+ - lib/pansophy_authenticator/configuration/verification/local.rb
244
+ - lib/pansophy_authenticator/configuration/verification/remote.rb
245
+ - lib/pansophy_authenticator/configuration/verification/result.rb
246
+ - lib/pansophy_authenticator/configuration/verification/verify.rb
227
247
  - lib/pansophy_authenticator/local.rb
228
248
  - lib/pansophy_authenticator/local/build_loader.rb
229
249
  - lib/pansophy_authenticator/local/fetcher.rb