Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

USH-228 - Upgrade project dependencies #4527

Merged
merged 32 commits into from
Mar 29, 2023
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
599fce7
chore: update laravel framework to 5.6
webong Feb 28, 2023
acb5ef7
chore: update laravel to 5.7
webong Feb 28, 2023
977256a
chore: update to laravel 5.8
webong Feb 28, 2023
4120beb
chore: upgrade to 6.0
webong Feb 28, 2023
bce2485
chore: update laravel to 7.0
webong Mar 1, 2023
1e54510
chore: added a wrapper for seeding datasets for tests and fixes to co…
webong Mar 1, 2023
76bfd89
chore: upgrade to laravel 8.0
webong Mar 1, 2023
db52c17
chore: update github action test to run php 8.0 instead of php 7.2
webong Mar 1, 2023
20098c4
chore: composer update
webong Mar 1, 2023
09ab7e0
mend
webong Mar 1, 2023
4abf6c2
chore: remove test for php 8.0, some dependencies are not compatible …
webong Mar 1, 2023
f01f564
fix: lint
webong Mar 1, 2023
c0afbce
chore: revert the version of phinx lib
webong Mar 1, 2023
3bade71
chore: modified github action workflow
webong Mar 1, 2023
806c2ec
chore: update phinx migration files
webong Mar 2, 2023
7f90aa0
chore: update to docker file and composer
webong Mar 2, 2023
7b50539
chore: remove test for php 7.4
webong Mar 2, 2023
d38c368
chore: modified composer.json
webong Mar 2, 2023
92fdd76
Merge remote-tracking branch 'origin/actions-update-202303' into chor…
webong Mar 9, 2023
a658c12
chore: update behat config file
webong Mar 10, 2023
dc58019
chore: modified the tests php files to be compatible with PSR standards.
webong Mar 10, 2023
3add9d8
Fixing file name casing
webong Mar 10, 2023
9f9ca65
chore: set sentry version constraints for composer and some modificat…
webong Mar 15, 2023
978c3fd
chore: added doc blocks citing to the feature tests database code
webong Mar 15, 2023
c1b82d2
chore: adding ci support for php version 7.4 and 8.0
webong Mar 15, 2023
47a1bf6
chore: remove ci test for php 8.0
webong Mar 16, 2023
4f281ea
Merge remote-tracking branch 'origin/project-mzima' into chore/upgrad…
webong Mar 21, 2023
5e26f8c
Merge branch 'project-mzima' into chore/upgrade-dependencies
Mh-Asmi Mar 26, 2023
c42260f
remove extra line after namespace
Mh-Asmi Mar 26, 2023
df4e501
Update SurveyResource.php
Mh-Asmi Mar 26, 2023
aeea1d0
chore: fix V5 Resource not extending correct class
Mar 29, 2023
ae331ff
Merge branch 'project-mzima' into chore/upgrade-dependencies
webong Mar 29, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test-and-ship.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ jobs:
strategy:
matrix:
php_version:
- 7.2
- 7.3
tuxpiper marked this conversation as resolved.
Show resolved Hide resolved
- 7.4

steps:
- uses: actions/checkout@v3
Expand Down
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ FROM ushahidi/php-fpm-nginx:php-7.3
WORKDIR /var/www
COPY composer.json ./
COPY composer.lock ./
RUN composer self-update --2
tuxpiper marked this conversation as resolved.
Show resolved Hide resolved
RUN composer install --no-autoloader --no-scripts

COPY . .
Expand Down
33 changes: 0 additions & 33 deletions Homestead.yaml

This file was deleted.

28 changes: 16 additions & 12 deletions app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,23 @@

namespace App\Exceptions;

use Exception;
use Throwable;
use Asm89\Stack\CorsService;
use Illuminate\Auth\AuthenticationException;
use Ushahidi\Core\Exception\NotFoundException;
use Ushahidi\Core\Exception\ValidatorException;
use Ushahidi\Core\Exception\AuthorizerException;
use Ushahidi\Core\Exception\ThrottlingException;
use Illuminate\Auth\Access\AuthorizationException;
use Illuminate\Http\Exceptions\HttpResponseException;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use League\OAuth2\Server\Exception\OAuthServerException;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
use Illuminate\Validation\ValidationException as LaravelValidationException;
use Ushahidi\Core\Exception\AuthorizerException;
use Ushahidi\Core\Exception\NotFoundException;
use Ushahidi\Core\Exception\ThrottlingException;
use Ushahidi\Core\Exception\ValidatorException;
use Laravel\Passport\Exceptions\OAuthServerException as LaravelOAuthServerException;
use League\OAuth2\Server\Exception\OAuthServerException as LeagueOAuthServerException;

class Handler extends ExceptionHandler
{
Expand All @@ -32,7 +33,8 @@ class Handler extends ExceptionHandler
HttpException::class,
ModelNotFoundException::class,
LaravelValidationException::class,
OAuthServerException::class,
LaravelOAuthServerException::class,
LeagueOAuthServerException::class,
];

/**
Expand All @@ -49,14 +51,14 @@ class Handler extends ExceptionHandler
* Report or log an exception.
*
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
* @param \Throwable $exception
*
* @param \Exception $exception
* @return void
*/
public function report(Exception $exception)
public function report(Throwable $exception)
{
if ($this->shouldReport($exception) && app()->bound('sentry')) {
app('sentry')->captureException($exception);
\Sentry\Laravel\Facade::captureException($exception);
}

parent::report($exception);
Expand All @@ -66,15 +68,17 @@ public function report(Exception $exception)
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $exception
* @param \Throwable $exception
* @return \Illuminate\Http\Response
*/
public function render($request, Exception $exception)
public function render($request, Throwable $exception)
{
// First handle some special cases
if ($exception instanceof HttpResponseException) {
// @todo check if we should still reformat this for json
return $exception->getResponse();
} elseif ($exception instanceof LaravelOAuthServerException) {
return $exception->render($request);
} elseif ($exception instanceof ModelNotFoundException) {
$exception = new NotFoundHttpException($exception->getMessage(), $exception);
} elseif ($exception instanceof AuthorizationException) {
Expand Down
4 changes: 2 additions & 2 deletions app/Http/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ class Kernel extends HttpKernel
* @var array
*/
protected $middleware = [
\App\Http\Middleware\TrustProxies::class,
\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
\App\Http\Middleware\TrimStrings::class,
// \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
\App\Http\Middleware\TrustProxies::class,
\App\Http\Middleware\AddContentLength::class,
\Barryvdh\Cors\HandleCors::class,
\Fruitcake\Cors\HandleCors::class,
\App\Http\Middleware\SetLocale::class,
];

Expand Down
12 changes: 3 additions & 9 deletions app/Http/Middleware/TrustProxies.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,9 @@ class TrustProxies extends Middleware
protected $proxies = '**';

/**
* The current proxy header mappings.
* The headers that should be used to detect proxies.
*
* @var array
* @var int
*/
protected $headers = [
Request::HEADER_FORWARDED => 'FORWARDED',
Request::HEADER_X_FORWARDED_FOR => 'X_FORWARDED_FOR',
Request::HEADER_X_FORWARDED_HOST => 'X_FORWARDED_HOST',
Request::HEADER_X_FORWARDED_PORT => 'X_FORWARDED_PORT',
Request::HEADER_X_FORWARDED_PROTO => 'X_FORWARDED_PROTO',
];
protected $headers = Request::HEADER_X_FORWARDED_ALL;
}
26 changes: 20 additions & 6 deletions app/Passport/ClientRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\Passport;

use Illuminate\Support\Str;
use Ramsey\Uuid\Uuid as UUID;
use Laravel\Passport\Passport;
use Laravel\Passport\PersonalAccessClient;
Expand Down Expand Up @@ -93,16 +94,27 @@ public function personalAccessClient()
* @param int $userId
* @param string $name
* @param string $redirect
* @param string|null $provider
* @param bool $personalAccess
* @param bool $password
* @param bool $confidential
*
* @return Client
*/
public function create($userId, $name, $redirect, $personalAccess = false, $password = false)
{
public function create(
$userId,
$name,
$redirect,
$provider = null,
$personalAccess = false,
$password = false,
$confidential = true
) {
$client = (new Client)->forceFill([
'user_id' => $userId,
'name' => $name,
'secret' => str_random(40),
'provider' => $provider,
'secret' => ($confidential || $personalAccess) ? Str::random(40) : null,
'redirect' => $redirect,
'personal_access_client' => $personalAccess,
'password_client' => $password,
Expand Down Expand Up @@ -135,11 +147,13 @@ public function createPersonalAccessClient($userId, $name, $redirect)
* @param int $userId
* @param string $name
* @param string $redirect
* @param string|null $provider
*
* @return Client
*/
public function createPasswordGrantClient($userId, $name, $redirect)
public function createPasswordGrantClient($userId, $name, $redirect, $provider = null)
{
return $this->create($userId, $name, $redirect, false, true);
return $this->create($userId, $name, $redirect, $provider, false, true);
}

/**
Expand Down Expand Up @@ -168,7 +182,7 @@ public function update(LaravelPassportClient $client, $name, $redirect)
public function regenerateSecret(LaravelPassportClient $client)
{
$client->forceFill([
'secret' => str_random(40),
'secret' => Str::random(40),
])->save();

return $client;
Expand Down
28 changes: 16 additions & 12 deletions app/Passport/TokenGuard.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,24 @@

use Exception;
use Firebase\JWT\JWT;
use Illuminate\Container\Container;
use Illuminate\Contracts\Auth\Guard;
use Illuminate\Contracts\Debug\ExceptionHandler;
use Illuminate\Contracts\Encryption\Encrypter;
use App\Auth\GenericUser;
use Laravel\Passport\Token;
use Illuminate\Http\Request;
use Laravel\Passport\ClientRepository as LaravelPassportClientRepository;
use Laravel\Passport\Passport;
use Laravel\Passport\Token;
use Illuminate\Container\Container;
use Illuminate\Contracts\Auth\Guard;
use Laravel\Passport\TransientToken;
use Laravel\Passport\TokenRepository;
use Nyholm\Psr7\Factory\Psr17Factory;
//use Illuminate\Contracts\Auth\UserProvider;
use Laravel\Passport\TransientToken;
use League\OAuth2\Server\Exception\OAuthServerException;
use League\OAuth2\Server\ResourceServer;
use Symfony\Bridge\PsrHttpMessage\Factory\DiactorosFactory;
use Illuminate\Contracts\Encryption\Encrypter;
use Illuminate\Contracts\Debug\ExceptionHandler;
use League\OAuth2\Server\Exception\OAuthServerException as LeagueException;
use Laravel\Passport\Exceptions\OAuthServerException;
use Ushahidi\Contracts\Repository\Entity\UserRepository;
use App\Auth\GenericUser;
use Symfony\Bridge\PsrHttpMessage\Factory\PsrHttpFactory;
use Laravel\Passport\ClientRepository as LaravelPassportClientRepository;

class TokenGuard //implements Guard
{
Expand Down Expand Up @@ -109,7 +111,9 @@ protected function authenticateViaBearerToken($request)
// First, we will convert the Symfony request to a PSR-7 implementation which will
// be compatible with the base OAuth2 library. The Symfony bridge can perform a
// conversion for us to a Zend Diactoros implementation of the PSR-7 request.
$psr = (new DiactorosFactory)->createRequest($request);
$psr17Factory = new Psr17Factory();
$psrHttpFactory = new PsrHttpFactory($psr17Factory, $psr17Factory, $psr17Factory, $psr17Factory);
$psr = $psrHttpFactory->createRequest($request);

try {
$psr = $this->server->validateAuthenticatedRequest($psr);
Expand Down Expand Up @@ -144,7 +148,7 @@ protected function authenticateViaBearerToken($request)
$user = new GenericUser($user->asArray());

return $token ? $user->withAccessToken($token) : null;
} catch (OAuthServerException $e) {
} catch (LeagueException $e) {
// Log the error
Container::getInstance()->make(
ExceptionHandler::class
Expand Down
7 changes: 5 additions & 2 deletions app/PlatformVerifier/Env.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace App\PlatformVerifier;

use Dotenv\Dotenv;

class Env
{
private static $NO_ENV = 'Required environment variables missing and no environment file found.';
Expand Down Expand Up @@ -40,8 +42,9 @@ public function verifyRequirements($console = true)
$success = [];

if ($this->envExists()) {
// load DotEnv for this script
(new \Dotenv\Dotenv(__DIR__.'/../../'))->load();
// load DotEnv for this script
$dotenv = Dotenv::createImmutable(__DIR__ . "/../../");
$dotenv->load();
}

$failures = false;
Expand Down
2 changes: 1 addition & 1 deletion behat.yml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ default:
suites:
default:
paths:
- %paths.base%/tests/Integration
- '%paths.base%/tests/Integration'
contexts:
- Ushahidi\Tests\Integration\Bootstrap\FeatureContext
- Ushahidi\Tests\Integration\Bootstrap\RestContext:
Expand Down
Loading