diff --git a/README.md b/README.md index c4f010c..502b11d 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ public function registerBundles() { $bundles = array( // ... - new Uecode\Bundle\ApiKeyBundle\UecodeApiKeyBundle(), + new \Uecode\Bundle\ApiKeyBundle\UecodeApiKeyBundle(), ); } ``` diff --git a/composer.json b/composer.json index f15bb5b..b6d1b6a 100644 --- a/composer.json +++ b/composer.json @@ -3,13 +3,16 @@ "description": "Creates an avenue for using ApiKey authentication for Symfony2. Requires FOSUserBundle.", "license": "Apache 2.0", "require": { - "php": "^5.3|^7.0", - "symfony/symfony": "^2.3|^3.0", - "friendsofsymfony/user-bundle": "^1|~2.0@dev" + "php": "^7.4|^8.0", + "symfony/dependency-injection": "^3.4", + "symfony/config": "^3.4|^4.0", + "symfony/http-foundation": "^3.4|^4.0", + "symfony/security-core": "^3.4|^4.0", + "friendsofsymfony/user-bundle": "^2.0" }, "autoload": { - "psr-0": { - "Uecode\\Bundle\\ApiKeyBundle": "src/" + "psr-4": { + "Uecode\\Bundle\\ApiKeyBundle\\": "src" } }, "authors": [ @@ -17,5 +20,8 @@ "name": "Aaron Scherer", "email": "aequasi@gmail.com" } - ] + ], + "require-dev": { + "phpstan/phpstan": "^1.10" + } } diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000..994cbd1 --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,8 @@ +parameters: + paths: + - src + + level: 2 + + ignoreErrors: + - '#Call to an undefined method Symfony\\Component\\Config\\Definition\\Builder\\NodeDefinition::children\(\)#' diff --git a/src/Uecode/Bundle/ApiKeyBundle/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php similarity index 100% rename from src/Uecode/Bundle/ApiKeyBundle/DependencyInjection/Configuration.php rename to src/DependencyInjection/Configuration.php diff --git a/src/Uecode/Bundle/ApiKeyBundle/DependencyInjection/Security/Factory/ApiKeyFactory.php b/src/DependencyInjection/Security/Factory/ApiKeyFactory.php similarity index 100% rename from src/Uecode/Bundle/ApiKeyBundle/DependencyInjection/Security/Factory/ApiKeyFactory.php rename to src/DependencyInjection/Security/Factory/ApiKeyFactory.php diff --git a/src/Uecode/Bundle/ApiKeyBundle/DependencyInjection/UecodeApiKeyExtension.php b/src/DependencyInjection/UecodeApiKeyExtension.php similarity index 100% rename from src/Uecode/Bundle/ApiKeyBundle/DependencyInjection/UecodeApiKeyExtension.php rename to src/DependencyInjection/UecodeApiKeyExtension.php index 4a4e9cf..84a21b1 100644 --- a/src/Uecode/Bundle/ApiKeyBundle/DependencyInjection/UecodeApiKeyExtension.php +++ b/src/DependencyInjection/UecodeApiKeyExtension.php @@ -2,10 +2,10 @@ namespace Uecode\Bundle\ApiKeyBundle\DependencyInjection; -use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\Config\FileLocator; -use Symfony\Component\HttpKernel\DependencyInjection\Extension; +use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Loader; +use Symfony\Component\HttpKernel\DependencyInjection\Extension; /** * @author Aaron Scherer diff --git a/src/Uecode/Bundle/ApiKeyBundle/Document/ApiKeyUser.php b/src/Document/ApiKeyUser.php similarity index 100% rename from src/Uecode/Bundle/ApiKeyBundle/Document/ApiKeyUser.php rename to src/Document/ApiKeyUser.php diff --git a/src/Uecode/Bundle/ApiKeyBundle/Entity/ApiKeyUser.php b/src/Entity/ApiKeyUser.php similarity index 100% rename from src/Uecode/Bundle/ApiKeyBundle/Entity/ApiKeyUser.php rename to src/Entity/ApiKeyUser.php diff --git a/src/Uecode/Bundle/ApiKeyBundle/Extractor/HeaderExtractor.php b/src/Extractor/HeaderExtractor.php similarity index 100% rename from src/Uecode/Bundle/ApiKeyBundle/Extractor/HeaderExtractor.php rename to src/Extractor/HeaderExtractor.php diff --git a/src/Uecode/Bundle/ApiKeyBundle/Extractor/KeyExtractor.php b/src/Extractor/KeyExtractor.php similarity index 100% rename from src/Uecode/Bundle/ApiKeyBundle/Extractor/KeyExtractor.php rename to src/Extractor/KeyExtractor.php diff --git a/src/Uecode/Bundle/ApiKeyBundle/Extractor/QueryExtractor.php b/src/Extractor/QueryExtractor.php similarity index 100% rename from src/Uecode/Bundle/ApiKeyBundle/Extractor/QueryExtractor.php rename to src/Extractor/QueryExtractor.php diff --git a/src/Uecode/Bundle/ApiKeyBundle/Model/ApiKeyUser.php b/src/Model/ApiKeyUser.php similarity index 100% rename from src/Uecode/Bundle/ApiKeyBundle/Model/ApiKeyUser.php rename to src/Model/ApiKeyUser.php index b4c842e..e6e4059 100755 --- a/src/Uecode/Bundle/ApiKeyBundle/Model/ApiKeyUser.php +++ b/src/Model/ApiKeyUser.php @@ -4,8 +4,8 @@ use FOS\UserBundle\Model\User as BaseUser; use FOS\UserBundle\Model\UserInterface; -use Symfony\Component\Security\Core\User\UserInterface as BaseUserInterface; use Symfony\Component\Security\Core\User\AdvancedUserInterface; +use Symfony\Component\Security\Core\User\UserInterface as BaseUserInterface; use Uecode\Bundle\ApiKeyBundle\Util\ApiKeyGenerator; class ApiKeyUser extends BaseUser implements UserInterface, AdvancedUserInterface, BaseUserInterface diff --git a/src/Uecode/Bundle/ApiKeyBundle/Resources/config/services.yml b/src/Resources/config/services.yml similarity index 100% rename from src/Uecode/Bundle/ApiKeyBundle/Resources/config/services.yml rename to src/Resources/config/services.yml diff --git a/src/Uecode/Bundle/ApiKeyBundle/Security/Authentication/Provider/ApiKeyProvider.php b/src/Security/Authentication/Provider/ApiKeyProvider.php similarity index 91% rename from src/Uecode/Bundle/ApiKeyBundle/Security/Authentication/Provider/ApiKeyProvider.php rename to src/Security/Authentication/Provider/ApiKeyProvider.php index a0ac2f1..a155559 100644 --- a/src/Uecode/Bundle/ApiKeyBundle/Security/Authentication/Provider/ApiKeyProvider.php +++ b/src/Security/Authentication/Provider/ApiKeyProvider.php @@ -2,24 +2,20 @@ namespace Uecode\Bundle\ApiKeyBundle\Security\Authentication\Provider; +use FOS\UserBundle\Model\UserInterface; use Symfony\Component\Security\Core\Authentication\Provider\AuthenticationProviderInterface; use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; use Symfony\Component\Security\Core\Exception\AuthenticationException; use Symfony\Component\Security\Core\User\ChainUserProvider; use Symfony\Component\Security\Core\User\UserProviderInterface; -use FOS\UserBundle\Model\UserInterface; use Uecode\Bundle\ApiKeyBundle\Security\Authentication\Token\ApiKeyUserToken; -use Uecode\Bundle\ApiKeyBundle\Security\Authentication\Provider\ApiKeyUserProviderInterface; /** * @author Aaron Scherer */ class ApiKeyProvider implements AuthenticationProviderInterface { - /** - * @var UserProviderInterface - */ - protected $userProvider; + private UserProviderInterface $userProvider; public function __construct(UserProviderInterface $userProvider) { @@ -31,7 +27,7 @@ public function __construct(UserProviderInterface $userProvider) * * @param TokenInterface $token The TokenInterface instance to authenticate * - * @return TokenInterface An authenticated TokenInterface instance, never null + * @return TokenInterface|null An authenticated TokenInterface instance, never null * * @throws AuthenticationException if the authentication fails */ @@ -50,6 +46,8 @@ public function authenticate(TokenInterface $token) return $result; } } + + return null; } /** diff --git a/src/Uecode/Bundle/ApiKeyBundle/Security/Authentication/Provider/ApiKeyUserProviderInterface.php b/src/Security/Authentication/Provider/ApiKeyUserProviderInterface.php similarity index 83% rename from src/Uecode/Bundle/ApiKeyBundle/Security/Authentication/Provider/ApiKeyUserProviderInterface.php rename to src/Security/Authentication/Provider/ApiKeyUserProviderInterface.php index 85b73fb..be03722 100644 --- a/src/Uecode/Bundle/ApiKeyBundle/Security/Authentication/Provider/ApiKeyUserProviderInterface.php +++ b/src/Security/Authentication/Provider/ApiKeyUserProviderInterface.php @@ -1,6 +1,9 @@ */ diff --git a/src/Uecode/Bundle/ApiKeyBundle/Security/Authentication/Provider/EmailUserProvider.php b/src/Security/Authentication/Provider/EmailUserProvider.php similarity index 94% rename from src/Uecode/Bundle/ApiKeyBundle/Security/Authentication/Provider/EmailUserProvider.php rename to src/Security/Authentication/Provider/EmailUserProvider.php index d5ca26d..b337632 100644 --- a/src/Uecode/Bundle/ApiKeyBundle/Security/Authentication/Provider/EmailUserProvider.php +++ b/src/Security/Authentication/Provider/EmailUserProvider.php @@ -1,7 +1,7 @@ stateless = true; diff --git a/src/Uecode/Bundle/ApiKeyBundle/Security/Authentication/Token/ApiKeyUserToken.php b/src/Security/Authentication/Token/ApiKeyUserToken.php similarity index 100% rename from src/Uecode/Bundle/ApiKeyBundle/Security/Authentication/Token/ApiKeyUserToken.php rename to src/Security/Authentication/Token/ApiKeyUserToken.php diff --git a/src/Uecode/Bundle/ApiKeyBundle/Security/Firewall/ApiKeyListener.php b/src/Security/Firewall/ApiKeyListener.php similarity index 100% rename from src/Uecode/Bundle/ApiKeyBundle/Security/Firewall/ApiKeyListener.php rename to src/Security/Firewall/ApiKeyListener.php index a684376..b741948 100644 --- a/src/Uecode/Bundle/ApiKeyBundle/Security/Firewall/ApiKeyListener.php +++ b/src/Security/Firewall/ApiKeyListener.php @@ -5,11 +5,11 @@ use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Event\GetResponseEvent; use Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface; -use Symfony\Component\Security\Core\Exception\AuthenticationException; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; +use Symfony\Component\Security\Core\Exception\AuthenticationException; use Symfony\Component\Security\Http\Firewall\ListenerInterface; -use Uecode\Bundle\ApiKeyBundle\Security\Authentication\Token\ApiKeyUserToken; use Uecode\Bundle\ApiKeyBundle\Extractor\KeyExtractor; +use Uecode\Bundle\ApiKeyBundle\Security\Authentication\Token\ApiKeyUserToken; /** * @author Aaron Scherer diff --git a/src/Uecode/Bundle/ApiKeyBundle/UecodeApiKeyBundle.php b/src/UecodeApiKeyBundle.php similarity index 100% rename from src/Uecode/Bundle/ApiKeyBundle/UecodeApiKeyBundle.php rename to src/UecodeApiKeyBundle.php index 9f6c0d1..5ebfe90 100644 --- a/src/Uecode/Bundle/ApiKeyBundle/UecodeApiKeyBundle.php +++ b/src/UecodeApiKeyBundle.php @@ -2,9 +2,9 @@ namespace Uecode\Bundle\ApiKeyBundle; +use Symfony\Bundle\SecurityBundle\DependencyInjection\SecurityExtension; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\HttpKernel\Bundle\Bundle; -use Symfony\Bundle\SecurityBundle\DependencyInjection\SecurityExtension; use Uecode\Bundle\ApiKeyBundle\DependencyInjection\Security\Factory\ApiKeyFactory; /** diff --git a/src/Uecode/Bundle/ApiKeyBundle/Util/ApiKeyGenerator.php b/src/Util/ApiKeyGenerator.php similarity index 100% rename from src/Uecode/Bundle/ApiKeyBundle/Util/ApiKeyGenerator.php rename to src/Util/ApiKeyGenerator.php diff --git a/src/Uecode/Bundle/ApiKeyBundle/Util/ApiKeyGeneratorInterface.php b/src/Util/ApiKeyGeneratorInterface.php similarity index 100% rename from src/Uecode/Bundle/ApiKeyBundle/Util/ApiKeyGeneratorInterface.php rename to src/Util/ApiKeyGeneratorInterface.php