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

refresh - use PSR-4, bump to PHP 7.4/8, allow Symfony 3/4 #32

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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 README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function registerBundles()
{
$bundles = array(
// ...
new Uecode\Bundle\ApiKeyBundle\UecodeApiKeyBundle(),
new \Uecode\Bundle\ApiKeyBundle\UecodeApiKeyBundle(),
);
}
```
Expand Down
18 changes: 12 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,25 @@
"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": [
{
"name": "Aaron Scherer",
"email": "[email protected]"
}
]
],
"require-dev": {
"phpstan/phpstan": "^1.10"
}
}
8 changes: 8 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
parameters:
paths:
- src

level: 2

ignoreErrors:
- '#Call to an undefined method Symfony\\Component\\Config\\Definition\\Builder\\NodeDefinition::children\(\)#'
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>
*/
class ApiKeyProvider implements AuthenticationProviderInterface
{
/**
* @var UserProviderInterface
*/
protected $userProvider;
private UserProviderInterface $userProvider;

public function __construct(UserProviderInterface $userProvider)
{
Expand All @@ -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
*/
Expand All @@ -50,6 +46,8 @@ public function authenticate(TokenInterface $token)
return $result;
}
}

return null;
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<?php

namespace Uecode\Bundle\ApiKeyBundle\Security\Authentication\Provider;

use Symfony\Component\Security\Core\User\UserInterface;

/**
* @author Gennady Telegin <[email protected]>
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
namespace Uecode\Bundle\ApiKeyBundle\Security\Authentication\Provider;

use FOS\UserBundle\Security\EmailUserProvider AS FOSUserProvider;
use FOS\UserBundle\Security\EmailUserProvider as FOSUserProvider;
use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
use Symfony\Component\Security\Core\User\UserInterface as SecurityUserInterface;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
namespace Uecode\Bundle\ApiKeyBundle\Security\Authentication\Provider;

use FOS\UserBundle\Security\UserProvider AS FOSUserProvider;
use FOS\UserBundle\Security\UserProvider as FOSUserProvider;
use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
use Symfony\Component\Security\Core\User\UserInterface as SecurityUserInterface;

Expand All @@ -15,9 +15,6 @@ class UserProvider extends FOSUserProvider implements ApiKeyUserProviderInterfac
*/
private $stateless = false;

/**
* {@inheritdoc}
*/
public function loadUserByApiKey($apiKey)
{
$this->stateless = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down