File tree Expand file tree Collapse file tree
scripts/entrypoint/passbolt Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -83,11 +83,21 @@ function migrate_command() {
8383}
8484
8585function 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
Original file line number Diff line number Diff line change @@ -83,11 +83,19 @@ function migrate_command() {
8383}
8484
8585function 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
Original file line number Diff line number Diff line change @@ -85,12 +85,22 @@ function migrate_command() {
8585}
8686
8787function 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
Original file line number Diff line number Diff line change 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
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
You can’t perform that action at this time.
0 commit comments