soar_authentication_token 0.0.1 → 0.0.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3cbc96c1ee8c188201345c363af477c5c885a4e7
4
- data.tar.gz: 5a718b299f018d0fac5776c4cb60fbe2fa55e23f
3
+ metadata.gz: 8e3c701d097f5b136e50e3f178c444e6b604f2da
4
+ data.tar.gz: 0178b46dd7f0e2a2a7d15e9cb73b422b00165d30
5
5
  SHA512:
6
- metadata.gz: 65eb924547cc77a57909cdab9cb9d2305b8f4f28cfeaad13d01077f30ce2f6aa4511fee72ec0b5dc49709545693f36505db700534edbd7cf429b6cce3b2a88b7
7
- data.tar.gz: ee4cce2df468e709959a2520460ce7c3bc63d915d3cf557d3afe3e95bb88f6b192defe62055ef20f33ca1a36e70f7200bf31894d20d811bac21f1923a722385b
6
+ metadata.gz: ede08945abe0fe5da8cdb4ce59f8fb7853bc52fdc3c9f160e0722b65a0fb2ac2b1c01efd3e8e20671df1d3ca8eab03ceac98f1777b5d72a2f2c0d49c161e970e
7
+ data.tar.gz: 0108db7ca629b57f7c5398764c98cdb208557aab62cdfec6e96d82d4b3bba7e7529ee5e3cbf240898191c5203130e3f67e2360051a4662cfa5247a95d1c2592c
@@ -5,6 +5,7 @@ $:.unshift File.expand_path("../../lib", bin_file)
5
5
 
6
6
  require 'soar_authentication_token'
7
7
  require 'yaml'
8
+ require 'json'
8
9
 
9
10
  class Main
10
11
 
@@ -16,7 +17,19 @@ class Main
16
17
  'private_key' => private_key,
17
18
  'public_key' => public_key
18
19
  }
20
+ puts "------------"
21
+ puts "YAML Format:"
22
+ puts "------------"
19
23
  print configuration.to_yaml
24
+ puts ""
25
+ puts "------------"
26
+ puts "JSON Format:"
27
+ puts "------------"
28
+ print configuration.to_json
29
+ puts ""
30
+ puts ""
31
+ puts "------------"
32
+
20
33
  end
21
34
  end
22
35
 
@@ -1,18 +1,18 @@
1
1
  require 'soar_xt'
2
2
  require 'jwt'
3
+ require 'securerandom'
3
4
 
4
5
  module SoarAuthenticationToken
5
6
  class TokenGenerator
6
7
  DEFAULT_CONFIGURATION = {
7
- :mode => 'local',
8
- :private_key => '',
9
- :url => ''
8
+ 'mode' => 'remote',
9
+ 'url' => ''
10
10
  } unless defined? DEFAULT_CONFIGURATION; DEFAULT_CONFIGURATION.freeze
11
11
 
12
12
  def initialize(configuration)
13
13
  @configuration = merge_with_default_configuration(configuration)
14
14
  validate_configuration
15
- @private_key = OpenSSL::PKey::EC.new(@configuration[:private_key])
15
+ @private_key = OpenSSL::PKey::EC.new(@configuration['private_key'])
16
16
  end
17
17
 
18
18
  def generate(authenticated_identifier:)
@@ -36,6 +36,7 @@ module SoarAuthenticationToken
36
36
  end
37
37
 
38
38
  def merge_with_default_configuration(configuration)
39
+ configuration = {} unless configuration
39
40
  Hash.deep_merge(DEFAULT_CONFIGURATION,configuration)
40
41
  end
41
42
  end
@@ -4,20 +4,20 @@ require 'jwt'
4
4
  module SoarAuthenticationToken
5
5
  class TokenValidator
6
6
  DEFAULT_CONFIGURATION = {
7
- :mode => 'local',
8
- :public_key => '',
9
- :url => ''
7
+ 'mode' => 'local',
8
+ 'public_key' => '',
9
+ 'url' => ''
10
10
  } unless defined? DEFAULT_CONFIGURATION; DEFAULT_CONFIGURATION.freeze
11
11
 
12
12
  def initialize(configuration)
13
13
  @configuration = merge_with_default_configuration(configuration)
14
14
  validate_configuration
15
- @public_key = OpenSSL::PKey::EC.new(@configuration[:public_key])
15
+ @public_key = OpenSSL::PKey::EC.new(@configuration['public_key'])
16
16
  @public_key.private_key = nil
17
17
  end
18
18
 
19
19
  def validate(authentication_token)
20
- return validate_locally(authentication_token) if 'local' == @configuration[:mode]
20
+ return validate_locally(authentication_token) if 'local' == @configuration['mode']
21
21
  return validate_remotely(authentication_token)
22
22
  end
23
23
 
@@ -1,3 +1,3 @@
1
1
  module SoarAuthenticationToken
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.2'
3
3
  end
@@ -8,12 +8,12 @@ describe SoarAuthenticationToken::TokenGenerator do
8
8
 
9
9
  before :each do
10
10
  generator_configuration = {
11
- :mode => 'local',
12
- :private_key => @private_key
11
+ 'mode' => 'local',
12
+ 'private_key' => @private_key
13
13
  }
14
14
  validator_configuration = {
15
- :mode => 'local',
16
- :public_key => @public_key
15
+ 'mode' => 'local',
16
+ 'public_key' => @public_key
17
17
  }
18
18
  @iut = SoarAuthenticationToken::TokenGenerator.new(generator_configuration)
19
19
  @validator = SoarAuthenticationToken::TokenValidator.new(validator_configuration)
@@ -8,16 +8,16 @@ describe SoarAuthenticationToken::TokenValidator do
8
8
  @invalid_private_key, @invalid_public_key = keypair_generator.generate
9
9
  @test_identifier = 'a@b.co.za'
10
10
  @valid_generator_configuration = {
11
- :mode => 'local',
12
- :private_key => @valid_private_key
11
+ 'mode' => 'local',
12
+ 'private_key' => @valid_private_key
13
13
  }
14
14
  @invalid_generator_configuration = {
15
- :mode => 'local',
16
- :private_key => @invalid_private_key
15
+ 'mode' => 'local',
16
+ 'private_key' => @invalid_private_key
17
17
  }
18
18
  @validator_configuration = {
19
- :mode => 'local',
20
- :public_key => @valid_public_key
19
+ 'mode' => 'local',
20
+ 'public_key' => @valid_public_key
21
21
  }
22
22
  @valid_generator = SoarAuthenticationToken::TokenGenerator.new(@valid_generator_configuration)
23
23
  @invalid_generator = SoarAuthenticationToken::TokenGenerator.new(@invalid_generator_configuration)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: soar_authentication_token
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Barney de Villiers