Skip to content

Commit 7089dce

Browse files
committed
Merge branch 'feature/PB-39303' into 'master'
feature/PB 39303 See merge request passbolt/passbolt_docker!227
2 parents e4e703b + 5c932f7 commit 7089dce

File tree

4 files changed

+34
-6
lines changed

4 files changed

+34
-6
lines changed

scripts/entrypoint/passbolt/entrypoint-rootless.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,9 @@ function migrate_command() {
7777
function jwt_keys_creation() {
7878
if [[ $PASSBOLT_PLUGINS_JWT_AUTHENTICATION_ENABLED == "true" && (! -f $passbolt_config/jwt/jwt.key || ! -f $passbolt_config/jwt/jwt.pem) ]]; then
7979
/usr/share/php/passbolt/bin/cake passbolt create_jwt_keys
80-
chmod 640 "$passbolt_config/jwt/jwt.key" && chown www-data:www-data "$passbolt_config/jwt/jwt.key"
81-
chmod 640 "$passbolt_config/jwt/jwt.pem" && chown www-data:www-data "$passbolt_config/jwt/jwt.pem"
80+
chmod 440 "$passbolt_config/jwt/jwt.key" && chown www-data:www-data "$passbolt_config/jwt/jwt.key"
81+
chmod 440 "$passbolt_config/jwt/jwt.pem" && chown www-data:www-data "$passbolt_config/jwt/jwt.pem"
82+
chmod 550 "$passbolt_config/jwt"
8283
fi
8384
}
8485

scripts/entrypoint/passbolt/entrypoint.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,11 @@ function migrate_command() {
7676

7777
function jwt_keys_creation() {
7878
if [[ $PASSBOLT_PLUGINS_JWT_AUTHENTICATION_ENABLED == "true" && (! -f $passbolt_config/jwt/jwt.key || ! -f $passbolt_config/jwt/jwt.pem) ]]; then
79+
chmod 770 "$passbolt_config/jwt"
7980
su -c '/usr/share/php/passbolt/bin/cake passbolt create_jwt_keys' -s /bin/bash www-data
80-
chmod 640 "$passbolt_config/jwt/jwt.key" && chown root:www-data "$passbolt_config/jwt/jwt.key"
81-
chmod 640 "$passbolt_config/jwt/jwt.pem" && chown root:www-data "$passbolt_config/jwt/jwt.pem"
81+
chmod 440 "$passbolt_config/jwt/jwt.key" && chown root:www-data "$passbolt_config/jwt/jwt.key"
82+
chmod 440 "$passbolt_config/jwt/jwt.pem" && chown root:www-data "$passbolt_config/jwt/jwt.pem"
83+
chmod 550 "$passbolt_config/jwt"
8284
fi
8385
}
8486

spec/docker_image/image_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@
176176
describe 'jwt configuration' do
177177
it 'should have the correct permissions' do
178178
expect(file(jwt_conf)).to be_a_directory
179-
expect(file(jwt_conf)).to be_mode 770
179+
expect(file(jwt_conf)).to be_mode 750
180180
expect(file(jwt_conf)).to be_owned_by($root_user)
181181
expect(file(jwt_conf)).to be_grouped_into($config_group)
182182
end

spec/docker_runtime/runtime_spec.rb

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@
5353
'DATASOURCES_DEFAULT_PASSWORD=±!@#$%^&*()_+=-}{|:;<>?',
5454
'DATASOURCES_DEFAULT_USERNAME=passbolt',
5555
'DATASOURCES_DEFAULT_DATABASE=passbolt',
56-
'PASSBOLT_SSL_FORCE=true'
56+
'PASSBOLT_SSL_FORCE=true',
57+
'PASSBOLT_PLUGINS_JWT_AUTHENTICATION_ENABLED=true'
5758
],
5859
'Image' => @image.id,
5960
'Binds' => $binds
@@ -74,6 +75,8 @@
7475
let(:passbolt_host) { @container.json['NetworkSettings']['IPAddress'] }
7576
let(:uri) { '/healthcheck/status.json' }
7677
let(:curl) { "curl -sk -o /dev/null -w '%{http_code}' -H 'Host: passbolt.local' https://#{passbolt_host}:#{$https_port}/#{uri}" }
78+
let(:jwt_conf) { "#{PASSBOLT_CONFIG_PATH + '/jwt'}" }
79+
let(:jwt_key_pair) { ["#{jwt_conf}/jwt.key", "#{jwt_conf}/jwt.pem"] }
7780

7881
let(:rootless_env_setup) do
7982
# The sed command needs to create a temporary file on the same directory as the destination file (/etc/cron.d).
@@ -167,6 +170,28 @@
167170
end
168171
end
169172

173+
describe 'jwt configuration' do
174+
it 'should have the correct permissions' do
175+
expect(file(jwt_conf)).to be_a_directory
176+
expect(file(jwt_conf)).to be_mode 550
177+
expect(file(jwt_conf)).to be_owned_by($root_user)
178+
expect(file(jwt_conf)).to be_grouped_into($config_group)
179+
end
180+
181+
describe 'JWT key file' do
182+
it 'should exist' do
183+
expect(file("#{jwt_conf}/jwt.key")).to exist
184+
expect(file("#{jwt_conf}/jwt.key")).to be_mode 440
185+
end
186+
end
187+
188+
describe 'JWT pem file' do
189+
it 'should exist' do
190+
expect(file("#{jwt_conf}/jwt.pem")).to exist
191+
expect(file("#{jwt_conf}/jwt.pem")).to be_mode 440
192+
end
193+
end
194+
end
170195
describe 'cron service' do
171196
context 'cron process' do
172197
it 'is running supervised' do

0 commit comments

Comments
 (0)