Skip to content

Commit

Permalink
Make 3.x default version (#455)
Browse files Browse the repository at this point in the history
Co-authored-by: Jay Are Galinada <73857985+jayaregalinadaflexisourceit@users.noreply.github.com>
  • Loading branch information
natepage and jayaregalinadaflexisourceit authored Dec 18, 2020
1 parent f2bbf17 commit 28b5c5a
Show file tree
Hide file tree
Showing 241 changed files with 759 additions and 6,952 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/split_packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- master
- 3.x

jobs:
split_packages:
Expand Down Expand Up @@ -45,11 +46,15 @@ jobs:
- id: previous_tag
uses: eonx-com/github-action-get-previous-tag@master

- id: branch_name
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"

- name: Split ${{ matrix.mapping.dir }}
uses: eonx-com/github-action-monorepo-split@master
env:
GITHUB_TOKEN: ${{ secrets.REPO_GITHUB_TOKEN }}
with:
branch: ${{ steps.branch_name.outputs.branch }}
package-directory: 'packages/${{ matrix.mapping.dir }}'
split-repository-organization: 'eonx-com'
split-repository-name: '${{ matrix.mapping.repo }}'
Expand Down
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"php": "^7.2",
"ext-json": "*",
"doctrine/orm": "^2.6",
"eonx-com/externals": "^1.0 || ^2.0",
"nesbot/carbon": "^2.22",
"dragonmantank/cron-expression": "^2.3",
"ramsey/uuid": "^3.9",
Expand Down
6 changes: 3 additions & 3 deletions packages/EasyApiToken/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"phpunit/phpunit": "^8.4 || ^9.5",
"ext-openssl": "^7.1",
"firebase/php-jwt": "^5.0",
"eonx-com/easy-psr7-factory": "^2.6",
"eonx-com/easy-utils": "^2.6",
"eonx-com/easy-psr7-factory": "^3.0",
"eonx-com/easy-utils": "^3.0",
"auth0/auth0-php": "^5.4",
"psr/container": "^1.0",
"laravel/lumen-framework": "^5.5",
Expand All @@ -36,7 +36,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "2.6-dev"
"dev-master": "3.0-dev"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
use EonX\EasyApiToken\Bridge\BridgeConstantsInterface;
use EonX\EasyApiToken\Factories\ApiTokenDecoderFactory;
use EonX\EasyApiToken\Interfaces\ApiTokenDecoderInterface;
use EonX\EasyApiToken\Interfaces\ApiTokenDecoderProviderInterface;
use EonX\EasyApiToken\Interfaces\Factories\ApiTokenDecoderFactoryInterface as DecoderFactoryInterface;
use EonX\EasyApiToken\Providers\FromConfigDecoderProvider;
use Illuminate\Support\ServiceProvider;

final class EasyApiTokenServiceProvider extends ServiceProvider
Expand All @@ -25,24 +23,6 @@ public function register(): void
{
$this->mergeConfigFrom(__DIR__ . '/config/easy-api-token.php', 'easy-api-token');

// TODO - Remove in 3.0.
if (empty(\config('easy-api-token.decoders', [])) === false) {
@\trigger_error(\sprintf(
'Defining ApiTokenDecoders using a config file is deprecated since 2.4 and will be removed in 3.0.
Use %s instead.',
ApiTokenDecoderProviderInterface::class
), \E_USER_NOTICE);

$this->app->singleton(FromConfigDecoderProvider::class, function (): FromConfigDecoderProvider {
return new FromConfigDecoderProvider(
\config('easy-api-token.decoders', []),
\config('easy-api-token.factories'),
\config('easy-api-token.default_decoder')
);
});
$this->app->tag(FromConfigDecoderProvider::class, [BridgeConstantsInterface::TAG_DECODER_PROVIDER]);
}

$this->app->singleton(ApiTokenDecoderInterface::class, function (): ApiTokenDecoderInterface {
return $this->app->make(DecoderFactoryInterface::class)->buildDefault();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,40 +23,8 @@ public function load(array $configs, ContainerBuilder $container): void
$loader = new PhpFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader->load('services.php');

$container->registerForAutoconfiguration(ApiTokenDecoderProviderInterface::class)
$container
->registerForAutoconfiguration(ApiTokenDecoderProviderInterface::class)
->addTag(BridgeConstantsInterface::TAG_DECODER_PROVIDER);

// Resolve config
$decoders = [];
$defaultFactories = null;
$defaultDecoder = null;

foreach ($configs as $config) {
if (isset($config['decoders'])) {
$decoders = $config['decoders'];
}

if (isset($config['default_decoder'])) {
$defaultDecoder = $config['default_decoder'];
}

if (isset($config['default_factories'])) {
$defaultFactories = $config['default_factories'];
}
}

if (empty($decoders) === false) {
@\trigger_error(\sprintf(
'Defining ApiTokenDecoders using a config file is deprecated since 2.4 and will be removed in 3.0.
Use %s instead.',
ApiTokenDecoderProviderInterface::class
), \E_USER_NOTICE);

$container->setParameter(BridgeConstantsInterface::PARAM_DECODERS, $decoders);
$container->setParameter(BridgeConstantsInterface::PARAM_DEFAULT_FACTORIES, $defaultFactories);
$container->setParameter(BridgeConstantsInterface::PARAM_DEFAULT_DECODER, $defaultDecoder);

$loader->load('from_config_provider.php');
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use EonX\EasyApiToken\Factories\ApiTokenDecoderFactory;
use EonX\EasyApiToken\Interfaces\ApiTokenDecoderInterface;
use EonX\EasyApiToken\Interfaces\Factories\ApiTokenDecoderFactoryInterface;
use EonX\EasyApiToken\Interfaces\Factories\EasyApiTokenDecoderFactoryInterface;

return static function (ContainerConfigurator $container): void {
$services = $container->services();
Expand All @@ -20,8 +19,6 @@
->set(ApiTokenDecoderFactoryInterface::class, ApiTokenDecoderFactory::class)
->arg('$decoderProviders', tagged_iterator(BridgeConstantsInterface::TAG_DECODER_PROVIDER));

$services->alias(EasyApiTokenDecoderFactoryInterface::class, ApiTokenDecoderFactoryInterface::class);

$services
->set(ApiTokenDecoderInterface::class)
->factory([ref(ApiTokenDecoderFactoryInterface::class), 'buildDefault']);
Expand Down

This file was deleted.

39 changes: 2 additions & 37 deletions packages/EasyApiToken/src/Decoders/AbstractApiTokenDecoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,11 @@ public function __construct(?string $name = null)

public function getName(): string
{
return $this->name ?? self::class;
return $this->name ?? static::class;
}

/**
* @param \Symfony\Component\HttpFoundation\Request|\Psr\Http\Message\ServerRequestInterface $request
*/
protected function getHeaderWithoutPrefix(string $header, string $prefix, $request): ?string
protected function getHeaderWithoutPrefix(string $header, string $prefix, Request $request): ?string
{
if ($request instanceof ServerRequestInterface) {
@\trigger_error(\sprintf(
'Passing $request as %s is deprecated since 2.4 and removed in 3.0. Use %s instead.',
ServerRequestInterface::class,
Request::class
), \E_USER_DEPRECATED);

return $this->getHeaderWithoutPrefixForServerRequest($header, $prefix, $request);
}

$header = $request->headers->get($header, '');

if (Strings::startsWith($header ?? '', $prefix) === false) {
Expand All @@ -63,26 +50,4 @@ protected function getQueryParam(string $param, ServerRequestInterface $request)

return $request->getQueryParams()[$param] ?? null;
}

private function getFirstHeaderValue(string $header, ServerRequestInterface $request): ?string
{
return $request->getHeader(\strtolower($header))[0] ?? null;
}

private function getHeaderWithoutPrefixForServerRequest(
string $header,
string $prefix,
ServerRequestInterface $request
): ?string {
if ($this->headerStartsWith($header, $prefix, $request) === false) {
return null;
}

return \substr((string)$this->getFirstHeaderValue($header, $request), \strlen($prefix));
}

private function headerStartsWith(string $header, string $prefix, ServerRequestInterface $request): bool
{
return Strings::startsWith($this->getFirstHeaderValue($header, $request) ?? '', $prefix);
}
}

This file was deleted.

6 changes: 2 additions & 4 deletions packages/EasyApiToken/src/Decoders/ApiKeyDecoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@

use EonX\EasyApiToken\Interfaces\ApiTokenInterface;
use EonX\EasyApiToken\Tokens\ApiKey;
use Symfony\Component\HttpFoundation\Request;

final class ApiKeyDecoder extends AbstractApiTokenDecoder
{
/**
* @param \Symfony\Component\HttpFoundation\Request|\Psr\Http\Message\ServerRequestInterface $request
*/
public function decode($request): ?ApiTokenInterface
public function decode(Request $request): ?ApiTokenInterface
{
$authorization = $this->getHeaderWithoutPrefix('Authorization', 'Basic', $request);

Expand Down
11 changes: 2 additions & 9 deletions packages/EasyApiToken/src/Decoders/BasicAuthDecoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,11 @@

use EonX\EasyApiToken\Interfaces\ApiTokenInterface;
use EonX\EasyApiToken\Tokens\BasicAuth;
use Symfony\Component\HttpFoundation\Request;

final class BasicAuthDecoder extends AbstractApiTokenDecoder
{
public function __construct(?string $name = null)
{
parent::__construct($name ?? self::NAME_BASIC);
}

/**
* @param \Symfony\Component\HttpFoundation\Request|\Psr\Http\Message\ServerRequestInterface $request
*/
public function decode($request): ?ApiTokenInterface
public function decode(Request $request): ?ApiTokenInterface
{
$authorization = $this->getHeaderWithoutPrefix('Authorization', 'Basic', $request);

Expand Down
6 changes: 2 additions & 4 deletions packages/EasyApiToken/src/Decoders/BearerTokenDecoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use EonX\EasyApiToken\Tokens\Jwt;
use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;
use Symfony\Component\HttpFoundation\Request;

final class BearerTokenDecoder extends AbstractApiTokenDecoder
{
Expand All @@ -30,10 +31,7 @@ public function __construct(JwtDriverInterface $jwtDriver, ?string $name = null,
parent::__construct($name);
}

/**
* @param \Symfony\Component\HttpFoundation\Request|\Psr\Http\Message\ServerRequestInterface $request
*/
public function decode($request): ?ApiTokenInterface
public function decode(Request $request): ?ApiTokenInterface
{
$authorization = $this->getHeaderWithoutPrefix('Authorization', 'Bearer', $request);

Expand Down
8 changes: 2 additions & 6 deletions packages/EasyApiToken/src/Decoders/ChainDecoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use EonX\EasyApiToken\Interfaces\ApiTokenDecoderInterface;
use EonX\EasyApiToken\Interfaces\ApiTokenInterface;
use EonX\EasyUtils\CollectorHelper;
use Symfony\Component\HttpFoundation\Request;

final class ChainDecoder extends AbstractApiTokenDecoder
{
Expand All @@ -25,10 +26,7 @@ public function __construct(array $decoders, ?string $name = null)
parent::__construct($name ?? self::NAME_CHAIN);
}

/**
* @param \Symfony\Component\HttpFoundation\Request|\Psr\Http\Message\ServerRequestInterface $request
*/
public function decode($request): ?ApiTokenInterface
public function decode(Request $request): ?ApiTokenInterface
{
foreach ($this->decoders as $decoder) {
$token = $decoder->decode($request);
Expand All @@ -41,5 +39,3 @@ public function decode($request): ?ApiTokenInterface
return null;
}
}

\class_alias(ChainDecoder::class, ChainReturnFirstTokenDecoder::class);
Loading

0 comments on commit 28b5c5a

Please sign in to comment.