soar_authentication_token 6.0.9 → 6.1.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: be301efe1e83558c9256e71f43bebad5e60f6864
4
- data.tar.gz: 6cbcf00b1f25fe8fcb7b4301bcfefabc25f7d82a
3
+ metadata.gz: 5a9cc03d1ae13d6ecbad2a427b4afb46a4f120df
4
+ data.tar.gz: 3397600cd607d46ab975edadd1845f3b6860ef2b
5
5
  SHA512:
6
- metadata.gz: 7b65232a85b3b4f09a70c4e94b0c37b552aeae9233a1b7e9f179b3f9d9a87fcc1602c635cef93500acb0f722c2ca7c9dcd81c69d7d1fe386937db6de74344f58
7
- data.tar.gz: a6caeb1f50d1fdbf787d1de36034481734932f027056081b29cce9a23edb5408560c28eb5087fa624980d4d9b244d7188c54b56178a04bf7dc125c854f542211
6
+ metadata.gz: 8b58ed52333c2550a63a4cf89a229368717c32f95ded4c08ee397de475963383dfd2acb5dd50c8434b5304dcbb4c0b4d2e0ecf0d1c0a16868ee3f3c85b86948f
7
+ data.tar.gz: 36fc7e74aa40a21229efca5f80fe9f9c9c804140706a33906351dd6fee4193483b6d43f95c29134a9832d1086a4544743aa3b09bd746ecaabd5e1fd6b8ab7ada
data/docker-compose.yml CHANGED
@@ -1,7 +1,7 @@
1
1
  version: '2.0'
2
2
  services:
3
3
  soar-authentication-token:
4
- command: /bin/bash -c 'sleep 5; bundle exec rspec -cfd ./spec/'
4
+ command: /bin/bash -c 'sleep 30; bundle exec rspec -cfd ./spec/'
5
5
  user: $UID:$UID
6
6
  build: .
7
7
  image: soar-authentication-token
@@ -11,4 +11,5 @@ require 'soar_authentication_token/config_rotator'
11
11
  require 'soar_authentication_token/token_generator'
12
12
  require 'soar_authentication_token/token_validator'
13
13
  require 'soar_authentication_token/rack_middleware'
14
+ require 'soar_authentication_token/rack_auth_id_transposer_middleware'
14
15
  require 'soar_authentication_token/version'
@@ -0,0 +1,19 @@
1
+ require 'rack'
2
+
3
+ module SoarAuthenticationToken
4
+ class RackAuthIdTransposerMiddleware
5
+ def initialize(app)
6
+ @app = app
7
+ end
8
+
9
+ def call(env)
10
+ request = Rack::Request.new env
11
+ authenticated_identifier = request.env['X-GATEWAY-AUTHENTICATED-IDENTIFIER']
12
+ if authenticated_identifier
13
+ request.session['user'] = authenticated_identifier
14
+ request.env['REMOTE_USER'] = authenticated_identifier
15
+ end
16
+ return @app.call env
17
+ end
18
+ end
19
+ end
@@ -1,3 +1,3 @@
1
1
  module SoarAuthenticationToken
2
- VERSION = '6.0.9'
2
+ VERSION = '6.1.0'
3
3
  end
@@ -0,0 +1,69 @@
1
+ require 'spec_helper'
2
+ require 'rack'
3
+ require 'rack/test'
4
+
5
+ describe SoarAuthenticationToken::RackAuthIdTransposerMiddleware do
6
+ include Rack::Test::Methods
7
+
8
+ before :each do
9
+ @test_app = lambda do |env|
10
+ request = Rack::Request.new env
11
+ session = request.session
12
+ test_app_response_data = {
13
+ 'message' => "tested",
14
+ 'session_user' => request.session['user'],
15
+ 'remote_user' => request.env['REMOTE_USER']
16
+ }
17
+ [200, {"Content-Type" => "application/json"}, test_app_response_data ]
18
+ end
19
+ @iut = SoarAuthenticationToken::RackAuthIdTransposerMiddleware.new(@test_app)
20
+ end
21
+
22
+ context "when initialized" do
23
+ it 'remembers the app provided' do
24
+ expect(@iut.instance_variable_get("@app")).to eq(@test_app)
25
+ end
26
+ end
27
+
28
+ context "when called with a request environment" do
29
+ context 'with X-GATEWAY-AUTHENTICATED-IDENTIFIER header' do
30
+ it "pass requests to the application" do
31
+ opts = { 'X-GATEWAY-AUTHENTICATED-IDENTIFIER' => 'test_uuid' }
32
+ code, env, body = @iut.call Rack::MockRequest.env_for('http://service', opts)
33
+ expect([code, env, body['message']]).to eq([200, {"Content-Type"=>"application/json"}, "tested"])
34
+ end
35
+
36
+ it "set the user key in the request session" do
37
+ opts = { 'X-GATEWAY-AUTHENTICATED-IDENTIFIER' => 'test_uuid' }
38
+ code, env, body = @iut.call Rack::MockRequest.env_for('http://service', opts)
39
+ expect(body['session_user']).to eq 'test_uuid'
40
+ end
41
+
42
+ it "set the remote user in the request environment" do
43
+ opts = { 'X-GATEWAY-AUTHENTICATED-IDENTIFIER' => 'test_uuid' }
44
+ code, env, body = @iut.call Rack::MockRequest.env_for('http://service', opts)
45
+ expect(body['remote_user']).to eq 'test_uuid'
46
+ end
47
+ end
48
+
49
+ context 'without X-GATEWAY-AUTHENTICATED-IDENTIFIER header' do
50
+ it "pass requests to the application" do
51
+ opts = { }
52
+ code, env, body = @iut.call Rack::MockRequest.env_for('http://service', opts)
53
+ expect([code, env, body['message'], body['session_user'], body['remote_user']]).to eq([200, {"Content-Type"=>"application/json"}, "tested", nil, nil])
54
+ end
55
+
56
+ it "does not modify the user key in the request session" do
57
+ opts = { }
58
+ code, env, body = @iut.call Rack::MockRequest.env_for('http://service', opts)
59
+ expect(body['session_user']).to eq nil
60
+ end
61
+
62
+ it "does not modify the remote user in the request environment" do
63
+ opts = { }
64
+ code, env, body = @iut.call Rack::MockRequest.env_for('http://service', opts)
65
+ expect(body['remote_user']).to eq nil
66
+ end
67
+ end
68
+ end
69
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: soar_authentication_token
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.9
4
+ version: 6.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Barney de Villiers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-26 00:00:00.000000000 Z
11
+ date: 2017-06-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: soar_xt
@@ -230,6 +230,7 @@ files:
230
230
  - lib/soar_authentication_token/providers/remote_token_generator.rb
231
231
  - lib/soar_authentication_token/providers/remote_token_validator.rb
232
232
  - lib/soar_authentication_token/providers/static_token_validator.rb
233
+ - lib/soar_authentication_token/rack_auth_id_transposer_middleware.rb
233
234
  - lib/soar_authentication_token/rack_middleware.rb
234
235
  - lib/soar_authentication_token/token_generator.rb
235
236
  - lib/soar_authentication_token/token_validator.rb
@@ -244,6 +245,7 @@ files:
244
245
  - spec/config_rotator_spec.rb
245
246
  - spec/jwt_token_validator_spec.rb
246
247
  - spec/keypair_generator_spec.rb
248
+ - spec/rack_auth_id_transposer_middleware_spec.rb
247
249
  - spec/rack_middleware_spec.rb
248
250
  - spec/remote_token_validator_spec.rb
249
251
  - spec/spec_helper.rb
@@ -278,6 +280,7 @@ test_files:
278
280
  - spec/config_rotator_spec.rb
279
281
  - spec/jwt_token_validator_spec.rb
280
282
  - spec/keypair_generator_spec.rb
283
+ - spec/rack_auth_id_transposer_middleware_spec.rb
281
284
  - spec/rack_middleware_spec.rb
282
285
  - spec/remote_token_validator_spec.rb
283
286
  - spec/spec_helper.rb