Skip to content

Commit

Permalink
Merge pull request #291 from silinternational/develop
Browse files Browse the repository at this point in the history
Release 7.0.3 -- trim whitespace
  • Loading branch information
briskt authored Sep 18, 2024
2 parents a6333a7 + 0b62c38 commit 6f00867
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 27 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/test-and-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ jobs:
tests:
name: Tests
runs-on: ubuntu-latest
timeout-minutes: ${{ fromJSON(vars.DEFAULT_JOB_TIMEOUT_MINUTES) }}
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand All @@ -21,6 +22,7 @@ jobs:
name: Build and Publish
needs: tests
runs-on: ubuntu-latest
timeout-minutes: ${{ fromJSON(vars.DEFAULT_JOB_TIMEOUT_MINUTES) }}
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand All @@ -34,6 +36,10 @@ jobs:
uses: docker/metadata-action@v5
with:
images: ${{ vars.DOCKER_ORG }}/${{ github.event.repository.name }}
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
Expand Down
12 changes: 6 additions & 6 deletions application/frontend/controllers/MethodController.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ public function init()
$config['baseUrl'],
$config['accessToken'],
[
IdBrokerClient::TRUSTED_IPS_CONFIG => $config['validIpRanges'] ?? [],
IdBrokerClient::ASSERT_VALID_BROKER_IP_CONFIG => $config['assertValidBrokerIp'] ?? true,
IdBrokerClient::TRUSTED_IPS_CONFIG => $config['validIpRanges'] ?? [],
IdBrokerClient::ASSERT_VALID_BROKER_IP_CONFIG => $config['assertValidBrokerIp'] ?? true,
]
);
}
Expand Down Expand Up @@ -114,8 +114,8 @@ public function actionCreate()

$request = \Yii::$app->request;

$value = $request->post('value');
if ($value === null) {
$value = trim($request->getBodyParam('value', ''));
if ($value === '') {
throw new BadRequestHttpException(\Yii::t('app', 'Method.MissingValue'), 1542750428);
}

Expand Down Expand Up @@ -157,8 +157,8 @@ public function actionVerify($uid)
429 => \Yii::t('app', 'Method.TooManyFailures'),
];

$code = \Yii::$app->request->getBodyParam('code');
if ($code === null) {
$code = trim(\Yii::$app->request->getBodyParam('code', ''));
if ($code === '') {
throw new BadRequestHttpException(\Yii::t('app', 'Method.CodeMissing'), 1542749426);
}

Expand Down
17 changes: 8 additions & 9 deletions application/frontend/controllers/MfaController.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ public function init()
$config['baseUrl'],
$config['accessToken'],
[
IdBrokerClient::TRUSTED_IPS_CONFIG => $config['validIpRanges'] ?? [],
IdBrokerClient::ASSERT_VALID_BROKER_IP_CONFIG => $config['assertValidBrokerIp'] ?? true,
IdBrokerClient::TRUSTED_IPS_CONFIG => $config['validIpRanges'] ?? [],
IdBrokerClient::ASSERT_VALID_BROKER_IP_CONFIG => $config['assertValidBrokerIp'] ?? true,
]
);
}
Expand Down Expand Up @@ -88,7 +88,7 @@ public function actionCreate(): ?array
throw new BadRequestHttpException(\Yii::t('app', 'Mfa.TypeMissing'));
}

$label = \Yii::$app->request->getBodyParam('label');
$label = trim(\Yii::$app->request->getBodyParam('label', ''));

try {
$mfa = $this->idBrokerClient->mfaCreate(
Expand Down Expand Up @@ -249,8 +249,7 @@ public function actionVerifyRegistration($mfaId)
throw new BadRequestHttpException(\Yii::t('app', 'Mfa.MissingValue'));
}

$label = \Yii::$app->request->getBodyParam('label');
$label = $label ?: '';
$label = trim(\Yii::$app->request->getBodyParam('label', ''));

try {
$mfa = $this->idBrokerClient->mfaVerify(
Expand Down Expand Up @@ -286,8 +285,8 @@ public function actionVerifyRegistration($mfaId)
*/
public function actionUpdate($mfaId)
{
$label = \Yii::$app->request->getBodyParam('label');
if (!$label) {
$label = trim(\Yii::$app->request->getBodyParam('label', ''));
if ($label === '') {
throw new BadRequestHttpException(\Yii::t('app', 'Mfa.MissingLabel'));
}

Expand Down Expand Up @@ -317,8 +316,8 @@ public function actionUpdate($mfaId)
*/
public function actionUpdateWebauthn($mfaId, $webauthnId)
{
$label = \Yii::$app->request->getBodyParam('label');
if (!$label) {
$label = trim(\Yii::$app->request->getBodyParam('label', ''));
if ($label === '') {
throw new BadRequestHttpException(\Yii::t('app', 'Mfa.MissingLabel'));
}

Expand Down
6 changes: 3 additions & 3 deletions application/frontend/controllers/PasswordController.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function actionAssess()

$testPassword = Password::create($user, $newPassword);

if (! $testPassword->validate('password')) {
if (!$testPassword->validate('password')) {
$errors = join(', ', $testPassword->getErrors('password'));
\Yii::warning([
'action' => 'password/assess',
Expand All @@ -110,8 +110,8 @@ public function actionAssess()
*/
protected function getPasswordFromRequestBody()
{
$newPassword = \Yii::$app->request->getBodyParam('password');
if ($newPassword === null) {
$newPassword = trim(\Yii::$app->request->getBodyParam('password', ''));
if ($newPassword === '') {
throw new BadRequestHttpException(\Yii::t('app', 'Password.MissingPassword'));
}
return $newPassword;
Expand Down
17 changes: 8 additions & 9 deletions application/frontend/controllers/ResetController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace frontend\controllers;

use common\components\passwordStore\AccountLockedException;
use common\components\personnel\NotFoundException;
use common\helpers\Utils;
use common\models\EventLog;
Expand Down Expand Up @@ -65,10 +64,10 @@ public function actionView($uid)
*/
public function actionCreate()
{
$username = \Yii::$app->request->post('username');
$verificationToken = \Yii::$app->request->post('verification_token');
$username = trim(\Yii::$app->request->getBodyParam('username', ''));
$verificationToken = trim(\Yii::$app->request->getBodyParam('verification_token', ''));

if (! $username) {
if ($username === '') {
throw new BadRequestHttpException(\Yii::t('app', 'Reset.MissingUsername'));
}

Expand All @@ -78,12 +77,12 @@ public function actionCreate()
* be double sure an exception is thrown.
*/
if (\Yii::$app->params['recaptcha']['required']) {
if (! $verificationToken) {
if ($verificationToken === '') {
throw new BadRequestHttpException(\Yii::t('app', 'Reset.MissingRecaptchaCode'));
}

$clientIp = Utils::getClientIp(\Yii::$app->request);
if (! Utils::isRecaptchaResponseValid($verificationToken, $clientIp)) {
if (!Utils::isRecaptchaResponseValid($verificationToken, $clientIp)) {
throw new BadRequestHttpException(\Yii::t('app', 'Reset.RecaptchaFailedVerification'));
}
}
Expand Down Expand Up @@ -294,7 +293,7 @@ public function actionValidate($uid)
/*
* Delete reset record, log errors, but let user proceed
*/
if (! $reset->delete()) {
if (!$reset->delete()) {
\Yii::warning([
'action' => 'delete reset after validation',
'reset_id' => $reset->id,
Expand Down Expand Up @@ -337,8 +336,8 @@ public function actionValidate($uid)
*/
protected function getCodeFromRequestBody(): string
{
$code = \Yii::$app->request->getBodyParam('code', null);
if ($code === null) {
$code = trim(\Yii::$app->request->getBodyParam('code', ''));
if ($code === '') {
throw new BadRequestHttpException(\Yii::t('app', 'Reset.MissingCode'), 1462989866);
}
return $code;
Expand Down

0 comments on commit 6f00867

Please sign in to comment.