Skip to content

Commit 8aecbcd

Browse files
committed
support symfony 4
1 parent bcb92e8 commit 8aecbcd

29 files changed

Lines changed: 2066 additions & 130 deletions

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,6 @@ vendor/
4444

4545
Tests/autoload.php
4646
Tests/phpunit.xml
47-
bin
47+
bin
48+
49+
.idea/*

.gitmodules

Lines changed: 0 additions & 3 deletions
This file was deleted.

.travis.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@ language: php
22

33
php:
44
- 5.3
5-
- 5.4
6-
- 5.5
7-
5+
- 7.0
86
before_script: composer install --dev
97

108
notifications:
119
email:
12-
- kotlyar.maksim@gmail.com
10+
- kotlyar.maksim@gmail.com

Bridge/RelyingParty/LightOpenIdRelyingParty.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?php
22
namespace Fp\OpenIdBundle\Bridge\RelyingParty;
33

4-
use Symfony\Component\HttpFoundation\Request;
5-
use Symfony\Component\HttpFoundation\RedirectResponse;
6-
4+
use Fp\OpenIdBundle\LightOpenId\LightOpenID;
75
use Fp\OpenIdBundle\RelyingParty\AbstractRelyingParty;
8-
use Fp\OpenIdBundle\RelyingParty\IdentityProviderResponse;
96
use Fp\OpenIdBundle\RelyingParty\Exception\OpenIdAuthenticationCanceledException;
107
use Fp\OpenIdBundle\RelyingParty\Exception\OpenIdAuthenticationValidationFailedException;
8+
use Fp\OpenIdBundle\RelyingParty\IdentityProviderResponse;
9+
use Symfony\Component\HttpFoundation\RedirectResponse;
10+
use Symfony\Component\HttpFoundation\Request;
1111

1212
class LightOpenIdRelyingParty extends AbstractRelyingParty
1313
{
@@ -44,16 +44,18 @@ protected function complete(Request $request)
4444
));
4545
}
4646

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

5050
/**
5151
* @param string $trustRoot
5252
*
53-
* @return \LightOpenID
53+
* @return LightOpenID
54+
*
55+
* @throws \ErrorException
5456
*/
5557
protected function createLightOpenID($trustRoot)
5658
{
57-
return new \LightOpenID($trustRoot);
59+
return new LightOpenID($trustRoot);
5860
}
59-
}
61+
}

Controller/SecurityController.php

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,16 @@
11
<?php
2+
23
namespace Fp\OpenIdBundle\Controller;
34

5+
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
6+
use Symfony\Component\HttpFoundation\Request;
47
use Symfony\Component\Security\Core\Security;
5-
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
6-
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
78

8-
class SecurityController implements ContainerAwareInterface
9+
class SecurityController extends Controller
910
{
10-
use ContainerAwareTrait;
11-
12-
public function loginAction()
11+
public function loginAction(Request $request)
1312
{
14-
$request = $this->container->get('request_stack')->getCurrentRequest();
15-
/* @var $request \Symfony\Component\HttpFoundation\Request */
1613
$session = $request->getSession();
17-
/* @var $session \Symfony\Component\HttpFoundation\Session\SessionInterface */
1814

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

34-
return $this->container->get('templating')->renderResponse(
35-
'FpOpenIdBundle:Security:login.html.'.$this->container->getParameter('fp_openid.template.engine'),
36-
array('error' => $error)
37-
);
30+
return $this->render('FpOpenIdBundle:Security:login.html.twig', [
31+
'error' => $error
32+
]);
3833
}
3934

4035
public function checkAction()

DependencyInjection/Configuration.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
class Configuration implements ConfigurationInterface
99
{
1010
/**
11-
*
1211
* {@inheritDoc}
1312
*/
1413
public function getConfigTreeBuilder()

DependencyInjection/FpOpenIdExtension.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function load(array $configs, ContainerBuilder $container)
2828

2929
/**
3030
* @param array $configs
31-
* @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
31+
* @param ContainerBuilder $container
3232
*
3333
* @throws \InvalidArgumentException
3434
*/
@@ -65,4 +65,4 @@ protected function loadDbDriver(array $configs, ContainerBuilder $container, $lo
6565

6666
$container->setParameter('fp_openid.model.identity.class', $identityClass);
6767
}
68-
}
68+
}

DependencyInjection/Security/Factory/OpenIdFactory.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
namespace Fp\OpenIdBundle\DependencyInjection\Security\Factory;
33

44
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
5+
use Symfony\Component\DependencyInjection\ChildDefinition;
56
use Symfony\Component\DependencyInjection\ContainerBuilder;
6-
use Symfony\Component\DependencyInjection\DefinitionDecorator;
77
use Symfony\Component\DependencyInjection\Reference;
88
use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\AbstractFactory;
99

@@ -92,7 +92,7 @@ protected function createAuthProvider(ContainerBuilder $container, $id, $config,
9292
{
9393
$providerId = 'security.authentication.provider.fp_openid.'.$id;
9494
$provider = $container
95-
->setDefinition($providerId, new DefinitionDecorator('security.authentication.provider.fp_openid'))
95+
->setDefinition($providerId, new ChildDefinition('security.authentication.provider.fp_openid'))
9696
->replaceArgument(0, $id);
9797

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

117117
$container
118-
->setDefinition($entryPointId, new DefinitionDecorator('security.authentication.form_entry_point'))
118+
->setDefinition($entryPointId, new ChildDefinition('security.authentication.form_entry_point'))
119119
->addArgument(new Reference('security.http_utils'))
120120
->addArgument($config['login_path'])
121121
->addArgument($config['use_forward'])
122122
;
123123

124124
return $entryPointId;
125125
}
126-
}
126+
}

Entity/IdentityManager.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
<?php
22
namespace Fp\OpenIdBundle\Entity;
33

4-
use Doctrine\ORM\EntityManager;
5-
6-
use Fp\OpenIdBundle\Model\IdentityManagerInterface;
4+
use Doctrine\ORM\EntityManagerInterface;
5+
use Doctrine\ORM\EntityRepository;
6+
use Doctrine\Persistence\ObjectRepository;
77
use Fp\OpenIdBundle\Model\IdentityInterface;
8+
use Fp\OpenIdBundle\Model\IdentityManagerInterface;
89

9-
class IdentityManager implements IdentityManagerInterface
10+
class IdentityManager implements IdentityManagerInterface
1011
{
1112
protected $entityManager;
1213

1314
protected $identityClass;
1415

15-
public function __construct(EntityManager $entityManager, $identityClass)
16+
public function __construct(EntityManagerInterface $entityManager, $identityClass)
1617
{
1718
$this->entityManager = $entityManager;
1819
$this->identityClass = $identityClass;
@@ -55,10 +56,10 @@ public function delete(IdentityInterface $identity)
5556
}
5657

5758
/**
58-
* @return \Doctrine\ORM\EntityRepository
59+
* @return ObjectRepository
5960
*/
6061
protected function getIdentityRepository()
6162
{
6263
return $this->entityManager->getRepository($this->identityClass);
6364
}
64-
}
65+
}

0 commit comments

Comments
 (0)