soar_authentication_token 3.0.1 → 3.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/docker-compose.yml +4 -2
- data/lib/soar_authentication_token/token_generator.rb +11 -9
- data/lib/soar_authentication_token/version.rb +1 -1
- data/soar_authentication_token.gemspec +0 -1
- data/spec/auth_client_spec.rb +41 -0
- data/spec/rack_middleware_spec.rb +2 -1
- data/spec/token_generator_spec.rb +2 -1
- data/spec/token_validator_spec.rb +3 -1
- metadata +3 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f65a1f8050aa7a3c6433614faa12ae71b3f2dbb3
|
4
|
+
data.tar.gz: f0715f429de1c7d386358b4f19f15a00cd361cd5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 700d5c18e4e8439a5f42fffb5a82ce2397331a94f85db82d7626ec0e173763c6de796bef39df192b61792671dd6fc70d327fe30f61a82663dbff55b231331681
|
7
|
+
data.tar.gz: ffcd9ffd9c7d9a97c64c87cb6f66ce95a140d4581606ecb9112a57911329e1dd40e98263a2a5b8072b4f5dd4b11d4759be38a3323664ecdc2aa661ca4d4ce402
|
data/docker-compose.yml
CHANGED
@@ -12,18 +12,20 @@ services:
|
|
12
12
|
authentication-token-generator-service:
|
13
13
|
build: authentication-token-generator-service
|
14
14
|
image: authentication-token-generator-service
|
15
|
+
command: soaring start -e production
|
15
16
|
expose:
|
16
17
|
- "9393"
|
17
18
|
volumes:
|
18
19
|
- ./authentication-token-generator-service:/usr/local/src/
|
19
20
|
environment:
|
20
|
-
- RACK_ENV=
|
21
|
+
- RACK_ENV=production
|
21
22
|
- ENVIRONMENT_FILE=environment_local_ecosystem.yml
|
22
23
|
links:
|
23
24
|
- authentication-token-store
|
24
25
|
authentication-token-validator-service:
|
25
26
|
build: authentication-token-validator-service
|
26
27
|
image: authentication-token-validator-service
|
28
|
+
command: soaring start -e production
|
27
29
|
expose:
|
28
30
|
- "9393"
|
29
31
|
volumes:
|
@@ -36,7 +38,7 @@ services:
|
|
36
38
|
authentication-token-store:
|
37
39
|
build: authentication-token-store
|
38
40
|
image: authentication-token-store
|
39
|
-
command: soaring start
|
41
|
+
command: soaring start -e development
|
40
42
|
expose:
|
41
43
|
- "9393"
|
42
44
|
environment:
|
@@ -37,16 +37,18 @@ module SoarAuthenticationToken
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def generate_remotely(authenticated_identifier,flow_identifier)
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
request.set_form_data({'flow_identifier' => flow_identifier})
|
44
|
-
request.body = { 'authenticated_identifier' => authenticated_identifier }.to_json
|
45
|
-
response = Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') { |http|
|
46
|
-
http.request request
|
47
|
-
}
|
40
|
+
client = authenticated_client(authenticated_identifier,flow_identifier)
|
41
|
+
validate_and_extract_token_from_response(client.request)
|
42
|
+
end
|
48
43
|
|
49
|
-
|
44
|
+
def authenticated_client(authenticated_identifier,flow_identifier)
|
45
|
+
client = SoarAuthenticationToken::AuthenticatedClient.new
|
46
|
+
client.url = @configuration['generator-url']
|
47
|
+
client.token = @configuration['generator-client-auth-token']
|
48
|
+
client.verb = :post
|
49
|
+
client.parameters = {'flow_identifier' => flow_identifier}
|
50
|
+
client.body = { 'authenticated_identifier' => authenticated_identifier }
|
51
|
+
client
|
50
52
|
end
|
51
53
|
|
52
54
|
def validate_and_extract_token_from_response(response)
|
@@ -22,7 +22,6 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.add_dependency 'soar_xt', '~> 0.0.3'
|
23
23
|
spec.add_dependency 'jwt', '~> 1.5', '>= 1.5.6'
|
24
24
|
spec.add_dependency "rack", '~> 1.6', '>= 1.6.4'
|
25
|
-
spec.add_dependency 'auth_token_store_provider', '~> 1.0.0'
|
26
25
|
|
27
26
|
spec.add_development_dependency 'pry', '~> 0'
|
28
27
|
spec.add_development_dependency 'bundler', '~> 1.3'
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SoarAuthenticationToken::AuthenticatedClient do
|
4
|
+
before :each do
|
5
|
+
end
|
6
|
+
|
7
|
+
it 'has a version number' do
|
8
|
+
expect(SoarAuthenticationToken::VERSION).not_to be nil
|
9
|
+
end
|
10
|
+
|
11
|
+
context "when performing an authenticated request" do
|
12
|
+
context "with a valid token" do
|
13
|
+
it 'respond with a successful request' do
|
14
|
+
@iut = SoarAuthenticationToken::AuthenticatedClient.new
|
15
|
+
@iut.url = 'http://authentication-token-generator-service:9393/generate'
|
16
|
+
@iut.token = 'test_ecosystem_token_for_auth_token_aaapi_authenticator_service'
|
17
|
+
@iut.verb = :post
|
18
|
+
@iut.parameters = {}
|
19
|
+
@iut.body = {}
|
20
|
+
@iut.auditing = nil
|
21
|
+
|
22
|
+
response = @iut.request
|
23
|
+
expect(response.code).to eq '200'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
context "with an invalid token" do
|
27
|
+
it 'respond unauthorized' do
|
28
|
+
@iut = SoarAuthenticationToken::AuthenticatedClient.new
|
29
|
+
@iut.url = 'http://authentication-token-generator-service:9393/generate'
|
30
|
+
@iut.token = 'invalid'
|
31
|
+
@iut.verb = :post
|
32
|
+
@iut.parameters = {}
|
33
|
+
@iut.body = {}
|
34
|
+
@iut.auditing = nil
|
35
|
+
|
36
|
+
response = @iut.request
|
37
|
+
expect(response.code).to eq '401'
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -10,7 +10,8 @@ describe SoarAuthenticationToken::RackMiddleware do
|
|
10
10
|
private_key, public_key = keypair_generator.generate
|
11
11
|
configuration = {
|
12
12
|
'mode' => 'remote',
|
13
|
-
'generator-url' => 'http://authentication-token-generator-service:9393/generate'
|
13
|
+
'generator-url' => 'http://authentication-token-generator-service:9393/generate',
|
14
|
+
'generator-client-auth-token' => 'test_ecosystem_token_for_auth_token_aaapi_authenticator_service'
|
14
15
|
}
|
15
16
|
generator = SoarAuthenticationToken::TokenGenerator.new(configuration)
|
16
17
|
generator.inject_store_provider(get_store)
|
@@ -19,7 +19,8 @@ describe SoarAuthenticationToken::TokenGenerator do
|
|
19
19
|
@configuration_remote = {
|
20
20
|
'mode' => 'remote',
|
21
21
|
'generator-url' => 'http://authentication-token-generator-service:9393/generate',
|
22
|
-
'validator-url' => 'http://authentication-token-validator-service:9393/validate'
|
22
|
+
'validator-url' => 'http://authentication-token-validator-service:9393/validate',
|
23
|
+
'generator-client-auth-token' => 'test_ecosystem_token_for_auth_token_aaapi_authenticator_service'
|
23
24
|
}
|
24
25
|
|
25
26
|
@test_store = AuthTokenStoreProvider::StubClient.new
|
@@ -54,10 +54,12 @@ describe SoarAuthenticationToken::TokenValidator do
|
|
54
54
|
@remote_generator_configuration = {
|
55
55
|
'mode' => 'remote',
|
56
56
|
'generator-url' => 'http://authentication-token-generator-service:9393/generate',
|
57
|
+
'generator-client-auth-token' => 'test_ecosystem_token_for_auth_token_aaapi_authenticator_service'
|
57
58
|
}
|
58
59
|
@remote_validator_configuration = {
|
59
60
|
'mode' => 'remote',
|
60
|
-
'validator-url' => 'http://authentication-token-validator-service:9393/validate'
|
61
|
+
'validator-url' => 'http://authentication-token-validator-service:9393/validate',
|
62
|
+
'generator-client-auth-token' => 'test_ecosystem_token_for_auth_token_aaapi_authenticator_service'
|
61
63
|
}
|
62
64
|
@local_valid_generator = SoarAuthenticationToken::TokenGenerator.new(@local_valid_generator_configuration)
|
63
65
|
@local_valid_generator.inject_store_provider(@test_store)
|
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: 3.0.
|
4
|
+
version: 3.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Barney de Villiers
|
@@ -64,20 +64,6 @@ dependencies:
|
|
64
64
|
- - ">="
|
65
65
|
- !ruby/object:Gem::Version
|
66
66
|
version: 1.6.4
|
67
|
-
- !ruby/object:Gem::Dependency
|
68
|
-
name: auth_token_store_provider
|
69
|
-
requirement: !ruby/object:Gem::Requirement
|
70
|
-
requirements:
|
71
|
-
- - "~>"
|
72
|
-
- !ruby/object:Gem::Version
|
73
|
-
version: 1.0.0
|
74
|
-
type: :runtime
|
75
|
-
prerelease: false
|
76
|
-
version_requirements: !ruby/object:Gem::Requirement
|
77
|
-
requirements:
|
78
|
-
- - "~>"
|
79
|
-
- !ruby/object:Gem::Version
|
80
|
-
version: 1.0.0
|
81
67
|
- !ruby/object:Gem::Dependency
|
82
68
|
name: pry
|
83
69
|
requirement: !ruby/object:Gem::Requirement
|
@@ -192,6 +178,7 @@ files:
|
|
192
178
|
- sanity/sanity.rb
|
193
179
|
- sanity/sanity_benchmark.rb
|
194
180
|
- soar_authentication_token.gemspec
|
181
|
+
- spec/auth_client_spec.rb
|
195
182
|
- spec/keypair_generator_spec.rb
|
196
183
|
- spec/rack_middleware_spec.rb
|
197
184
|
- spec/spec_helper.rb
|
@@ -222,6 +209,7 @@ signing_key:
|
|
222
209
|
specification_version: 4
|
223
210
|
summary: Client library for Hetzner's authentication token service
|
224
211
|
test_files:
|
212
|
+
- spec/auth_client_spec.rb
|
225
213
|
- spec/keypair_generator_spec.rb
|
226
214
|
- spec/rack_middleware_spec.rb
|
227
215
|
- spec/spec_helper.rb
|