Skip to content

Commit ea15b6d

Browse files
committed
Merge branch 'feature/PB-44058_JWT-keys-are-not-created-on-Docker-due-to-undefined-and-unnecessary-env-var' into 'master'
PB-44058 - Update JWT key function to create JWT by default following API changes See merge request passbolt/passbolt_docker!232
2 parents ce6aaaa + 953f77e commit ea15b6d

5 files changed

Lines changed: 44 additions & 17 deletions

File tree

scripts/entrypoint/passbolt/entrypoint-openshift.sh

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,21 @@ function migrate_command() {
8383
}
8484

8585
function jwt_keys_creation() {
86-
if [[ $PASSBOLT_PLUGINS_JWT_AUTHENTICATION_ENABLED == "true" && (! -f $passbolt_config/jwt/jwt.key || ! -f $passbolt_config/jwt/jwt.pem) ]]; then
86+
if [[ "${PASSBOLT_PLUGINS_JWT_AUTHENTICATION_ENABLED}" == "false" ]]; then
87+
return 0
88+
fi
89+
90+
if [[ ! -f "$passbolt_config/jwt/jwt.key" || ! -f "$passbolt_config/jwt/jwt.pem" ]]; then
91+
mkdir -p "$passbolt_config/jwt"
92+
chmod 770 "$passbolt_config/jwt"
93+
8794
/usr/share/php/passbolt/bin/cake passbolt create_jwt_keys
88-
chmod 440 "$passbolt_config/jwt/jwt.key" && chown www-data:0 "$passbolt_config/jwt/jwt.key"
89-
chmod 440 "$passbolt_config/jwt/jwt.pem" && chown www-data:0 "$passbolt_config/jwt/jwt.pem"
90-
chmod 550 "$passbolt_config/jwt"
95+
96+
chmod 640 "$passbolt_config/jwt/jwt.key"
97+
chown www-data:0 "$passbolt_config/jwt/jwt.key"
98+
chmod 640 "$passbolt_config/jwt/jwt.pem"
99+
chown www-data:0 "$passbolt_config/jwt/jwt.pem"
100+
chmod 750 "$passbolt_config/jwt"
91101
fi
92102
}
93103

scripts/entrypoint/passbolt/entrypoint-rootless.sh

100644100755
Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,19 @@ function migrate_command() {
8383
}
8484

8585
function jwt_keys_creation() {
86-
if [[ $PASSBOLT_PLUGINS_JWT_AUTHENTICATION_ENABLED == "true" && (! -f $passbolt_config/jwt/jwt.key || ! -f $passbolt_config/jwt/jwt.pem) ]]; then
86+
if [[ "${PASSBOLT_PLUGINS_JWT_AUTHENTICATION_ENABLED}" == "false" ]]; then
87+
return 0
88+
fi
89+
90+
if [[ ! -f "$passbolt_config/jwt/jwt.key" || ! -f "$passbolt_config/jwt/jwt.pem" ]]; then
91+
mkdir -p "$passbolt_config/jwt"
92+
chmod 770 "$passbolt_config/jwt"
93+
8794
/usr/share/php/passbolt/bin/cake passbolt create_jwt_keys
88-
chmod 440 "$passbolt_config/jwt/jwt.key" && chown www-data:www-data "$passbolt_config/jwt/jwt.key"
89-
chmod 440 "$passbolt_config/jwt/jwt.pem" && chown www-data:www-data "$passbolt_config/jwt/jwt.pem"
90-
chmod 550 "$passbolt_config/jwt"
95+
96+
chmod 640 "$passbolt_config/jwt/jwt.key"
97+
chmod 640 "$passbolt_config/jwt/jwt.pem"
98+
chmod 750 "$passbolt_config/jwt"
9199
fi
92100
}
93101

scripts/entrypoint/passbolt/entrypoint.sh

100644100755
Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,22 @@ function migrate_command() {
8585
}
8686

8787
function jwt_keys_creation() {
88-
if [[ $PASSBOLT_PLUGINS_JWT_AUTHENTICATION_ENABLED == "true" && (! -f $passbolt_config/jwt/jwt.key || ! -f $passbolt_config/jwt/jwt.pem) ]]; then
88+
if [[ "${PASSBOLT_PLUGINS_JWT_AUTHENTICATION_ENABLED}" == "false" ]]; then
89+
return 0
90+
fi
91+
92+
if [[ ! -f "$passbolt_config/jwt/jwt.key" || ! -f "$passbolt_config/jwt/jwt.pem" ]]; then
93+
mkdir -p "$passbolt_config/jwt"
8994
chmod 770 "$passbolt_config/jwt"
95+
chown www-data:www-data "$passbolt_config/jwt"
9096
su -c '/usr/share/php/passbolt/bin/cake passbolt create_jwt_keys' -s /bin/bash www-data
91-
chmod 440 "$passbolt_config/jwt/jwt.key" && chown root:www-data "$passbolt_config/jwt/jwt.key"
92-
chmod 440 "$passbolt_config/jwt/jwt.pem" && chown root:www-data "$passbolt_config/jwt/jwt.pem"
93-
chmod 550 "$passbolt_config/jwt"
97+
fi
98+
99+
if [[ -f "$passbolt_config/jwt/jwt.key" && -f "$passbolt_config/jwt/jwt.pem" ]]; then
100+
chmod 640 "$passbolt_config/jwt/jwt.key"
101+
chmod 640 "$passbolt_config/jwt/jwt.pem"
102+
chmod 750 "$passbolt_config/jwt"
103+
chown -Rf root:www-data "$passbolt_config/jwt"
94104
fi
95105
}
96106

scripts/entrypoint/passbolt/env.sh

100644100755
File mode changed.

spec/docker_runtime/runtime_spec.rb

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,7 @@
6060
'DATASOURCES_DEFAULT_PASSWORD=±!@#$%^&*()_+=-}{|:;<>?',
6161
'DATASOURCES_DEFAULT_USERNAME=passbolt',
6262
'DATASOURCES_DEFAULT_DATABASE=passbolt',
63-
'PASSBOLT_SSL_FORCE=true',
64-
'PASSBOLT_PLUGINS_JWT_AUTHENTICATION_ENABLED=true'
63+
'PASSBOLT_SSL_FORCE=true'
6564
]
6665
container_env = @container_env.clone
6766

@@ -399,22 +398,22 @@
399398
describe 'jwt configuration' do
400399
it 'should have the correct permissions' do
401400
expect(file(jwt_conf)).to be_a_directory
402-
expect(file(jwt_conf)).to be_mode 550
401+
expect(file(jwt_conf)).to be_mode 750
403402
expect(file(jwt_conf)).to be_owned_by($root_user)
404403
expect(file(jwt_conf)).to be_grouped_into($config_group)
405404
end
406405

407406
describe 'JWT key file' do
408407
it 'should exist' do
409408
expect(file("#{jwt_conf}/jwt.key")).to exist
410-
expect(file("#{jwt_conf}/jwt.key")).to be_mode 440
409+
expect(file("#{jwt_conf}/jwt.key")).to be_mode 640
411410
end
412411
end
413412

414413
describe 'JWT pem file' do
415414
it 'should exist' do
416415
expect(file("#{jwt_conf}/jwt.pem")).to exist
417-
expect(file("#{jwt_conf}/jwt.pem")).to be_mode 440
416+
expect(file("#{jwt_conf}/jwt.pem")).to be_mode 640
418417
end
419418
end
420419
end

0 commit comments

Comments
 (0)