conjur-rack 3.1.0 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +9 -0
- data/Jenkinsfile +63 -0
- data/conjur-rack.gemspec +2 -2
- data/lib/conjur/rack/user.rb +12 -4
- data/lib/conjur/rack/version.rb +1 -1
- data/publish.sh +7 -0
- data/spec/rack/user_spec.rb +74 -42
- data/{jenkins.sh → test.sh} +1 -1
- metadata +10 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e7a94d29090dcdb5515723b50f1f0217be932a96574e9d46c9f7e84abd3a3cb3
|
4
|
+
data.tar.gz: 3a011098248a61fa80a92e3085f07f71e18b8748867e3c44cc6c174dc922e69f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a11e49c31d758257c79b508dc3f30c500310962e2420d4c31adf7b83a706f44618ea11350a53e5fdda8dc0a1173082cbf84dea8616493e3733730e42c31714cc
|
7
|
+
data.tar.gz: ce37831b5f5eb108a1637db47bfd73b823eec4bde8e55a3ceafcedccd98dba7f53a8007578931fec18021fd36e174fffd991cc8caf0327622fcdfe3638ba44a5
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
# unreleased version
|
2
|
+
|
3
|
+
# v4.0.0
|
4
|
+
|
5
|
+
* Bump `rack` to v2, `bundler` to v1.16 in gemspec
|
6
|
+
* Add Jenkinsfile to project
|
7
|
+
* Ignore headers such as Conjur-Privilege or Conjur-Audit if they're not
|
8
|
+
supported by the API (instead of erroring out).
|
9
|
+
|
1
10
|
# v3.1.0
|
2
11
|
|
3
12
|
* Support for JWT Slosilo tokens.
|
data/Jenkinsfile
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
pipeline {
|
2
|
+
agent { label 'executor-v2' }
|
3
|
+
|
4
|
+
options {
|
5
|
+
timestamps()
|
6
|
+
buildDiscarder(logRotator(daysToKeepStr: '30'))
|
7
|
+
}
|
8
|
+
|
9
|
+
stages {
|
10
|
+
stage('Run tests') {
|
11
|
+
steps {
|
12
|
+
sh './test.sh'
|
13
|
+
|
14
|
+
junit 'spec/reports/*.xml'
|
15
|
+
}
|
16
|
+
}
|
17
|
+
|
18
|
+
// Only publish to RubyGems if the HEAD is
|
19
|
+
// tagged with the same version as in version.rb
|
20
|
+
stage('Publish to RubyGems') {
|
21
|
+
agent { label 'releaser-v2' }
|
22
|
+
|
23
|
+
when {
|
24
|
+
expression { currentBuild.resultIsBetterOrEqualTo('SUCCESS') }
|
25
|
+
branch "master"
|
26
|
+
expression {
|
27
|
+
def exitCode = sh returnStatus: true, script: ''' set +x
|
28
|
+
echo "Determining if publishing is requested..."
|
29
|
+
|
30
|
+
VERSION=`cat lib/conjur/rack/version.rb | grep VERSION | sed 's/.* "//;s/"//'`
|
31
|
+
echo Declared version: $VERSION
|
32
|
+
|
33
|
+
# Jenkins git plugin is broken and always fetches with `--no-tags`
|
34
|
+
# (or `--tags`, neither of which is what you want), so tags end up
|
35
|
+
# not being fetched. Try to fix that.
|
36
|
+
# (Unfortunately this fetches all remote heads, so we may have to find
|
37
|
+
# another solution for bigger repos.)
|
38
|
+
git fetch -q
|
39
|
+
|
40
|
+
# note when tag not found git rev-parse will just print its name
|
41
|
+
TAG=`git rev-list -n 1 "v$VERSION" 2>/dev/null || :`
|
42
|
+
echo Tag v$VERSION: $TAG
|
43
|
+
|
44
|
+
HEAD=`git rev-parse HEAD`
|
45
|
+
echo HEAD: $HEAD
|
46
|
+
|
47
|
+
test "$HEAD" = "$TAG"
|
48
|
+
'''
|
49
|
+
return exitCode == 0
|
50
|
+
}
|
51
|
+
}
|
52
|
+
steps {
|
53
|
+
sh './publish.sh'
|
54
|
+
}
|
55
|
+
}
|
56
|
+
}
|
57
|
+
|
58
|
+
post {
|
59
|
+
always {
|
60
|
+
cleanupAndNotify(currentBuild.currentResult)
|
61
|
+
}
|
62
|
+
}
|
63
|
+
}
|
data/conjur-rack.gemspec
CHANGED
@@ -20,9 +20,9 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.add_dependency "slosilo", "~> 2.1"
|
22
22
|
spec.add_dependency "conjur-api", "< 6"
|
23
|
-
spec.add_dependency "rack", '~>
|
23
|
+
spec.add_dependency "rack", '~> 2'
|
24
24
|
|
25
|
-
spec.add_development_dependency "bundler", "~> 1.
|
25
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
26
26
|
spec.add_development_dependency "rake"
|
27
27
|
spec.add_development_dependency "rspec"
|
28
28
|
spec.add_development_dependency 'ci_reporter_rspec'
|
data/lib/conjur/rack/user.rb
CHANGED
@@ -37,7 +37,9 @@ module Conjur
|
|
37
37
|
# actually have that privilege according to the Conjur server.
|
38
38
|
def validated_global_privilege
|
39
39
|
unless @validated_global_privilege
|
40
|
-
@privilege = nil
|
40
|
+
@privilege = nil unless @privilege &&
|
41
|
+
api.respond_to?(:global_privilege_permitted?) &&
|
42
|
+
api.global_privilege_permitted?(@privilege)
|
41
43
|
@validated_global_privilege = true
|
42
44
|
end
|
43
45
|
@privilege
|
@@ -91,9 +93,15 @@ module Conjur
|
|
91
93
|
args = [ token ]
|
92
94
|
args.push remote_ip if remote_ip
|
93
95
|
api = cls.new_from_token(*args)
|
94
|
-
|
95
|
-
|
96
|
-
|
96
|
+
|
97
|
+
# These are features not present in some API versions.
|
98
|
+
# Test for them and only apply if it makes sense. Ignore otherwise.
|
99
|
+
%i(privilege audit_resources audit_roles).each do |feature|
|
100
|
+
meth = "with_#{feature}".intern
|
101
|
+
if api.respond_to?(meth) && (value = send(feature))
|
102
|
+
api = api.send meth, value
|
103
|
+
end
|
104
|
+
end
|
97
105
|
|
98
106
|
api
|
99
107
|
end
|
data/lib/conjur/rack/version.rb
CHANGED
data/publish.sh
ADDED
data/spec/rack/user_spec.rb
CHANGED
@@ -69,22 +69,34 @@ describe Conjur::Rack::User do
|
|
69
69
|
end
|
70
70
|
|
71
71
|
describe "#global_reveal?" do
|
72
|
+
let(:api){ double "conjur-api" }
|
73
|
+
before { allow(subject).to receive(:api).and_return(api) }
|
74
|
+
|
72
75
|
context "with global privilege" do
|
73
76
|
let(:privilege) { "reveal" }
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
+
|
78
|
+
context "when not supported" do
|
79
|
+
before { expect(api).not_to respond_to :global_privilege_permitted? }
|
80
|
+
it "simply returns false" do
|
81
|
+
expect(subject.global_reveal?).to be false
|
82
|
+
end
|
77
83
|
end
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
+
|
85
|
+
context "when supported" do
|
86
|
+
before do
|
87
|
+
allow(api).to receive(:global_privilege_permitted?).with('reveal') { true }
|
88
|
+
end
|
89
|
+
it "checks the API function global_privilege_permitted?" do
|
90
|
+
expect(subject.global_reveal?).to be true
|
91
|
+
# The result is cached
|
92
|
+
expect(api).not_to receive :global_privilege_permitted?
|
93
|
+
subject.global_reveal?
|
94
|
+
end
|
84
95
|
end
|
85
96
|
end
|
97
|
+
|
86
98
|
context "without a global privilege" do
|
87
|
-
it "simply returns
|
99
|
+
it "simply returns false" do
|
88
100
|
expect(subject.global_reveal?).to be false
|
89
101
|
end
|
90
102
|
end
|
@@ -98,51 +110,71 @@ describe Conjur::Rack::User do
|
|
98
110
|
expect(subject.api(cls)).to eq('the api')
|
99
111
|
end
|
100
112
|
end
|
113
|
+
|
101
114
|
context 'when not given args' do
|
102
|
-
|
103
|
-
|
115
|
+
let(:api) { double :api }
|
116
|
+
before do
|
117
|
+
allow(Conjur::API).to receive(:new_from_token).with(token).and_return(api)
|
104
118
|
end
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
expect(Conjur::API).to receive(:new_from_token).with(token).and_return('the api')
|
109
|
-
}
|
110
|
-
it_should_behave_like "builds the api"
|
119
|
+
|
120
|
+
it "builds the api from token" do
|
121
|
+
expect(subject.api).to eq api
|
111
122
|
end
|
123
|
+
|
112
124
|
context "with remote_ip" do
|
113
125
|
let(:remote_ip) { "the-ip" }
|
114
|
-
|
115
|
-
expect(Conjur::API).to receive(:new_from_token).with(token, 'the-ip').and_return(
|
116
|
-
|
117
|
-
|
126
|
+
it "passes the IP to the API constructor" do
|
127
|
+
expect(Conjur::API).to receive(:new_from_token).with(token, 'the-ip').and_return(api)
|
128
|
+
expect(subject.api).to eq api
|
129
|
+
end
|
118
130
|
end
|
131
|
+
|
119
132
|
context "with privilege" do
|
120
133
|
let(:privilege) { "elevate" }
|
121
|
-
|
122
|
-
expect(
|
123
|
-
expect(api).to
|
124
|
-
|
125
|
-
it_should_behave_like "builds the api"
|
134
|
+
it "applies the privilege on the API object" do
|
135
|
+
expect(api).to receive(:with_privilege).with("elevate").and_return "privileged api"
|
136
|
+
expect(subject.api).to eq "privileged api"
|
137
|
+
end
|
126
138
|
end
|
127
139
|
|
128
|
-
context "
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
140
|
+
context "when audit supported" do
|
141
|
+
before do
|
142
|
+
# If we're testing on an API version that doesn't
|
143
|
+
# support audit this method will be missing, so stub.
|
144
|
+
unless Conjur::API.respond_to? :decode_audit_ids
|
145
|
+
# not exactly a faithful reimplementation, but good enough for here
|
146
|
+
allow(Conjur::API).to receive(:decode_audit_ids) {|x|[x]}
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
context "with audit resource" do
|
151
|
+
let (:audit_resources) { 'food:bacon' }
|
152
|
+
it "applies the audit resource on the API object" do
|
153
|
+
expect(api).to receive(:with_audit_resources).with(['food:bacon']).and_return('the api')
|
154
|
+
expect(subject.api).to eq 'the api'
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
context "with audit roles" do
|
159
|
+
let (:audit_roles) { 'user:cook' }
|
160
|
+
it "applies the audit role on the API object" do
|
161
|
+
expect(api).to receive(:with_audit_roles).with(['user:cook']).and_return('the api')
|
162
|
+
expect(subject.api).to eq 'the api'
|
163
|
+
end
|
164
|
+
end
|
135
165
|
end
|
136
166
|
|
137
|
-
context "
|
138
|
-
|
139
|
-
|
140
|
-
expect(
|
141
|
-
|
142
|
-
}
|
143
|
-
|
167
|
+
context "when audit not supported" do
|
168
|
+
before do
|
169
|
+
expect(api).not_to respond_to :with_audit_resources
|
170
|
+
expect(api).not_to respond_to :with_audit_roles
|
171
|
+
end
|
172
|
+
let (:audit_resources) { 'food:bacon' }
|
173
|
+
let (:audit_roles) { 'user:cook' }
|
174
|
+
it "ignores audit roles and resources" do
|
175
|
+
expect(subject.api).to eq api
|
176
|
+
end
|
144
177
|
end
|
145
|
-
|
146
178
|
end
|
147
179
|
end
|
148
180
|
|
data/{jenkins.sh → test.sh}
RENAMED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: conjur-rack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 4.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin Gilpin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-04-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: slosilo
|
@@ -44,28 +44,28 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '2'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '2'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: bundler
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '1.
|
61
|
+
version: '1.16'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '1.
|
68
|
+
version: '1.16'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rake
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -147,21 +147,23 @@ files:
|
|
147
147
|
- ".project"
|
148
148
|
- CHANGELOG.md
|
149
149
|
- Gemfile
|
150
|
+
- Jenkinsfile
|
150
151
|
- LICENSE.txt
|
151
152
|
- README.md
|
152
153
|
- Rakefile
|
153
154
|
- conjur-rack.gemspec
|
154
|
-
- jenkins.sh
|
155
155
|
- lib/conjur/rack.rb
|
156
156
|
- lib/conjur/rack/authenticator.rb
|
157
157
|
- lib/conjur/rack/path_prefix.rb
|
158
158
|
- lib/conjur/rack/user.rb
|
159
159
|
- lib/conjur/rack/version.rb
|
160
|
+
- publish.sh
|
160
161
|
- spec/rack/authenticator_spec.rb
|
161
162
|
- spec/rack/path_prefix_spec.rb
|
162
163
|
- spec/rack/user_spec.rb
|
163
164
|
- spec/rack_spec.rb
|
164
165
|
- spec/spec_helper.rb
|
166
|
+
- test.sh
|
165
167
|
homepage: http://github.com/conjurinc/conjur-rack
|
166
168
|
licenses:
|
167
169
|
- Private
|
@@ -182,7 +184,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
182
184
|
version: '0'
|
183
185
|
requirements: []
|
184
186
|
rubyforge_project:
|
185
|
-
rubygems_version: 2.6
|
187
|
+
rubygems_version: 2.7.6
|
186
188
|
signing_key:
|
187
189
|
specification_version: 4
|
188
190
|
summary: Rack authenticator and basic User struct
|