diff --git a/.github/workflows/test-and-publish.yml b/.github/workflows/test-and-publish.yml index 978db171..12286f90 100644 --- a/.github/workflows/test-and-publish.yml +++ b/.github/workflows/test-and-publish.yml @@ -14,9 +14,9 @@ jobs: - name: Checkout code uses: actions/checkout@v4 - name: Check PSR2 - run: docker-compose -f actions-services.yml run --rm app ./check-psr2.sh + run: docker compose -f actions-services.yml run --rm app ./check-psr12.sh - name: Run unit tests - run: docker-compose -f actions-services.yml run --rm app ./run-tests.sh + run: docker compose -f actions-services.yml run --rm app ./run-tests.sh build-and-publish: name: Build and Publish diff --git a/Makefile b/Makefile index 90d9b392..787515a1 100644 --- a/Makefile +++ b/Makefile @@ -1,72 +1,72 @@ start: app app: db composer - docker-compose up -d app phpmyadmin + docker compose up -d app phpmyadmin appfortests: testdb composerfortests - docker-compose up -d appfortests + docker compose up -d appfortests bash: - docker-compose run --rm cli bash + docker compose run --rm cli bash composer: - docker-compose run --rm cli composer install + docker compose run --rm cli composer install composerfortests: - docker-compose run --rm appfortests composer install - docker-compose run --rm dynamorestart composer install + docker compose run --rm appfortests composer install + docker compose run --rm dynamorestart composer install composershow: - docker-compose run --rm cli bash -c 'composer show --format=json --no-dev --no-ansi --locked | jq "[.locked[] | { \"name\": .name, \"version\": .version }]" > dependencies.json' + docker compose run --rm cli bash -c 'composer show --format=json --no-dev --no-ansi --locked | jq "[.locked[] | { \"name\": .name, \"version\": .version }]" > dependencies.json' composerupdate: - docker-compose run --rm cli composer update + docker compose run --rm cli composer update make composershow db: - docker-compose up -d db + docker compose up -d db testdb: - docker-compose up -d testdb + docker compose up -d testdb tables: db - docker-compose run --rm cli whenavail db 3306 100 ./yii migrate --interactive=0 + docker compose run --rm cli whenavail db 3306 100 ./yii migrate --interactive=0 tablesfortests: testdb - docker-compose run --rm appfortests whenavail testdb 3306 100 ./yii migrate --interactive=0 + docker compose run --rm appfortests whenavail testdb 3306 100 ./yii migrate --interactive=0 basemodels: db tables - docker-compose run --rm cli whenavail db 3306 100 ./rebuildbasemodels.sh + docker compose run --rm cli whenavail db 3306 100 ./rebuildbasemodels.sh quicktest: - docker-compose run --rm test bash -c "vendor/bin/behat --stop-on-failure --strict --append-snippets" + docker compose run --rm test bash -c "vendor/bin/behat --stop-on-failure --strict --append-snippets" test: appfortests - docker-compose run --rm test + docker compose run --rm test testcli: appfortests tablesfortests mfaapi - docker-compose run --rm test bash + docker compose run --rm test bash mfaapi: - docker-compose up -d mfaapi + docker compose up -d mfaapi # This is needed to re-run certain feature tests in testcli without stopping that container. dynamoclean: - docker-compose kill dynamorestart - docker-compose up -d dynamorestart + docker compose kill dynamorestart + docker compose up -d dynamorestart clean: - docker-compose kill - docker-compose rm -f + docker compose kill + docker compose rm -f raml2html: touch api.html - docker-compose run --rm raml2html + docker compose run --rm raml2html psr2: - docker-compose run --rm cli bash -c "vendor/bin/php-cs-fixer fix ." + docker compose run --rm cli bash -c "vendor/bin/php-cs-fixer fix ." callGA: app - docker-compose exec app bash -c "./yii ga/register_event" + docker compose exec app bash -c "./yii ga/register_event" diff --git a/actions-services.yml b/actions-services.yml index 864c4b8f..e1dbc44e 100644 --- a/actions-services.yml +++ b/actions-services.yml @@ -1,4 +1,3 @@ -version: '2' services: testdb: image: mariadb:10 diff --git a/application/check-psr2.sh b/application/check-psr12.sh similarity index 71% rename from application/check-psr2.sh rename to application/check-psr12.sh index 76e53f6f..be9343ea 100755 --- a/application/check-psr2.sh +++ b/application/check-psr12.sh @@ -4,18 +4,18 @@ cd /data composer install --no-interaction --no-scripts --no-progress -# Check the code against PSR-2. +# Check the code against PSR-12. vendor/bin/php-cs-fixer fix -v --dry-run --stop-on-violation --using-cache=no . -# If it didn't match PSR-2, then exit. +# If it didn't match PSR-12, then exit. rc=$?; if [[ $rc != 0 ]]; then echo ------------------------------------------------------------------------------ - echo Please run \"make psr2\" to format the code as PSR-2, then commit those changes. + echo Please run \"make psr2\" to format the code as PSR-12, then commit those changes. echo ------------------------------------------------------------------------------ exit $rc; fi echo ------------------------------------------------- -echo All PHP files appear to match PSR-2 requirements. +echo All PHP files appear to match PSR-12 requirements. echo ------------------------------------------------- diff --git a/application/frontend/controllers/AuthenticationController.php b/application/frontend/controllers/AuthenticationController.php index dcd18127..3ba4d352 100644 --- a/application/frontend/controllers/AuthenticationController.php +++ b/application/frontend/controllers/AuthenticationController.php @@ -27,7 +27,10 @@ public function actionCreate(): User // rpOrigin is needed for WebAuthn authentication $rpOrigin = \Yii::$app->request->get('rpOrigin', ''); if ($rpOrigin != '' && !in_array($rpOrigin, \Yii::$app->params['authorizedRPOrigins'])) { - throw new ForbiddenHttpException("Invalid rpOrigin", 1639169238); + $message = "Invalid rpOrigin. Received " . $rpOrigin . " authorized " . + var_export(\Yii::$app->params['authorizedRPOrigins'], true); + \Yii::error($message); + throw new ForbiddenHttpException($message, 1639169238); } $authentication = new Authentication( diff --git a/application/frontend/controllers/MfaController.php b/application/frontend/controllers/MfaController.php index 7cf3520b..d71341e3 100644 --- a/application/frontend/controllers/MfaController.php +++ b/application/frontend/controllers/MfaController.php @@ -138,7 +138,10 @@ public function actionList(string $employeeId): array // rpOrigin is needed for WebAuthn authentication $rpOrigin = \Yii::$app->request->get('rpOrigin', ''); if ($rpOrigin != '' && !in_array($rpOrigin, \Yii::$app->params['authorizedRPOrigins'])) { - throw new ForbiddenHttpException("Invalid rpOrigin", 1638378156); + $message = "Invalid rpOrigin. Received " . $rpOrigin . " authorized " . + var_export(\Yii::$app->params['authorizedRPOrigins'], true); + \Yii::error($message); + throw new ForbiddenHttpException($message, 1638378156); } $mfaOptions = Mfa::findAll(['user_id' => $user->id, 'verified' => 1]); diff --git a/docker-compose.yml b/docker-compose.yml index 5bf0c2be..7ca4ba9a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -195,8 +195,8 @@ services: U2F_SIM_HOST_AND_PORT: u2fsim:8080 command: ./run-tests.sh # running isolated tests - # docker-compose run --rm test vendor/bin/behat --stop-on-failure features/user.feature - # docker-compose run --rm test vendor/bin/behat --stop-on-failure features/user.feature:306 + # docker compose run --rm test vendor/bin/behat --stop-on-failure features/user.feature + # docker compose run --rm test vendor/bin/behat --stop-on-failure features/user.feature:306 phpmyadmin: image: phpmyadmin:5