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

support symfony 4 #113

Open
wants to merge 1 commit 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
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,6 @@ vendor/

Tests/autoload.php
Tests/phpunit.xml
bin
bin

.idea/*
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

6 changes: 2 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ language: php

php:
- 5.3
- 5.4
- 5.5

- 7.0
before_script: composer install --dev

notifications:
email:
- [email protected]
- [email protected]
18 changes: 10 additions & 8 deletions Bridge/RelyingParty/LightOpenIdRelyingParty.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?php
namespace Fp\OpenIdBundle\Bridge\RelyingParty;

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RedirectResponse;

use Fp\OpenIdBundle\LightOpenId\LightOpenID;
use Fp\OpenIdBundle\RelyingParty\AbstractRelyingParty;
use Fp\OpenIdBundle\RelyingParty\IdentityProviderResponse;
use Fp\OpenIdBundle\RelyingParty\Exception\OpenIdAuthenticationCanceledException;
use Fp\OpenIdBundle\RelyingParty\Exception\OpenIdAuthenticationValidationFailedException;
use Fp\OpenIdBundle\RelyingParty\IdentityProviderResponse;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;

class LightOpenIdRelyingParty extends AbstractRelyingParty
{
Expand Down Expand Up @@ -44,16 +44,18 @@ protected function complete(Request $request)
));
}

return new IdentityProviderResponse($lightOpenId->identity, $lightOpenId->getAttributes());
return new IdentityProviderResponse($lightOpenId->data['openid_identity'], $lightOpenId->getAttributes());
}

/**
* @param string $trustRoot
*
* @return \LightOpenID
* @return LightOpenID
*
* @throws \ErrorException
*/
protected function createLightOpenID($trustRoot)
{
return new \LightOpenID($trustRoot);
return new LightOpenID($trustRoot);
}
}
}
21 changes: 8 additions & 13 deletions Controller/SecurityController.php
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
<?php

namespace Fp\OpenIdBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Security\Core\Security;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;

class SecurityController implements ContainerAwareInterface
class SecurityController extends Controller
{
use ContainerAwareTrait;

public function loginAction()
public function loginAction(Request $request)
{
$request = $this->container->get('request_stack')->getCurrentRequest();
/* @var $request \Symfony\Component\HttpFoundation\Request */
$session = $request->getSession();
/* @var $session \Symfony\Component\HttpFoundation\Session\SessionInterface */

// get the error if any (works with forward and redirect -- see below)
if ($request->attributes->has(Security::AUTHENTICATION_ERROR)) {
Expand All @@ -31,10 +27,9 @@ public function loginAction()
$error = $error->getMessage();
}

return $this->container->get('templating')->renderResponse(
'FpOpenIdBundle:Security:login.html.'.$this->container->getParameter('fp_openid.template.engine'),
array('error' => $error)
);
return $this->render('FpOpenIdBundle:Security:login.html.twig', [
'error' => $error
]);
}

public function checkAction()
Expand Down
1 change: 0 additions & 1 deletion DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
class Configuration implements ConfigurationInterface
{
/**
*
* {@inheritDoc}
*/
public function getConfigTreeBuilder()
Expand Down
4 changes: 2 additions & 2 deletions DependencyInjection/FpOpenIdExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function load(array $configs, ContainerBuilder $container)

/**
* @param array $configs
* @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
* @param ContainerBuilder $container
*
* @throws \InvalidArgumentException
*/
Expand Down Expand Up @@ -65,4 +65,4 @@ protected function loadDbDriver(array $configs, ContainerBuilder $container, $lo

$container->setParameter('fp_openid.model.identity.class', $identityClass);
}
}
}
8 changes: 4 additions & 4 deletions DependencyInjection/Security/Factory/OpenIdFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
namespace Fp\OpenIdBundle\DependencyInjection\Security\Factory;

use Symfony\Component\Config\Definition\Builder\NodeDefinition;
use Symfony\Component\DependencyInjection\ChildDefinition;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\DefinitionDecorator;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\AbstractFactory;

Expand Down Expand Up @@ -92,7 +92,7 @@ protected function createAuthProvider(ContainerBuilder $container, $id, $config,
{
$providerId = 'security.authentication.provider.fp_openid.'.$id;
$provider = $container
->setDefinition($providerId, new DefinitionDecorator('security.authentication.provider.fp_openid'))
->setDefinition($providerId, new ChildDefinition('security.authentication.provider.fp_openid'))
->replaceArgument(0, $id);

// with user provider
Expand All @@ -115,12 +115,12 @@ protected function createEntryPoint($container, $id, $config, $defaultEntryPoint
$entryPointId = 'security.authentication.form_entry_point.'.$id;

$container
->setDefinition($entryPointId, new DefinitionDecorator('security.authentication.form_entry_point'))
->setDefinition($entryPointId, new ChildDefinition('security.authentication.form_entry_point'))
->addArgument(new Reference('security.http_utils'))
->addArgument($config['login_path'])
->addArgument($config['use_forward'])
;

return $entryPointId;
}
}
}
15 changes: 8 additions & 7 deletions Entity/IdentityManager.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
<?php
namespace Fp\OpenIdBundle\Entity;

use Doctrine\ORM\EntityManager;

use Fp\OpenIdBundle\Model\IdentityManagerInterface;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
use Doctrine\Persistence\ObjectRepository;
use Fp\OpenIdBundle\Model\IdentityInterface;
use Fp\OpenIdBundle\Model\IdentityManagerInterface;

class IdentityManager implements IdentityManagerInterface
class IdentityManager implements IdentityManagerInterface
{
protected $entityManager;

protected $identityClass;

public function __construct(EntityManager $entityManager, $identityClass)
public function __construct(EntityManagerInterface $entityManager, $identityClass)
{
$this->entityManager = $entityManager;
$this->identityClass = $identityClass;
Expand Down Expand Up @@ -55,10 +56,10 @@ public function delete(IdentityInterface $identity)
}

/**
* @return \Doctrine\ORM\EntityRepository
* @return ObjectRepository
*/
protected function getIdentityRepository()
{
return $this->entityManager->getRepository($this->identityClass);
}
}
}
Loading