Permalink
Browse files

fix sf21 changes in security.

  • Loading branch information...
1 parent 0b915cd commit a32a2e021445ef8004fa22e26a9f642519dd8990 @makasim makasim committed Jul 16, 2012
@@ -14,8 +14,10 @@ class OpenIdFactory extends AbstractFactory
*/
public function __construct()
{
+ $this->defaultSuccessHandlerOptions['login_path'] = '/login_openid';
+ $this->defaultFailureHandlerOptions['login_path'] = '/login_openid';
+
$this->addOption('create_user_if_not_exists', false);
- $this->addOption('login_path', '/login_openid');
}
/**
@@ -22,14 +22,14 @@
*/
private $relyingParty;
- public function __construct(SecurityContextInterface $securityContext, AuthenticationManagerInterface $authenticationManager, SessionAuthenticationStrategyInterface $sessionStrategy, HttpUtils $httpUtils, $providerKey, array $options = array(), AuthenticationSuccessHandlerInterface $successHandler = null, AuthenticationFailureHandlerInterface $failureHandler = null, LoggerInterface $logger = null, EventDispatcherInterface $dispatcher = null)
+ public function __construct(SecurityContextInterface $securityContext, AuthenticationManagerInterface $authenticationManager, SessionAuthenticationStrategyInterface $sessionStrategy, HttpUtils $httpUtils, $providerKey, AuthenticationSuccessHandlerInterface $successHandler, AuthenticationFailureHandlerInterface $failureHandler, array $options = array(), LoggerInterface $logger = null, EventDispatcherInterface $dispatcher = null)
{
$options = array_merge(array(
'required_attributes' => array(),
'optional_attributes' => array(),
), $options);
-
- parent::__construct($securityContext, $authenticationManager, $sessionStrategy, $httpUtils,$providerKey, $options, $successHandler, $failureHandler, $logger, $dispatcher);
+
+ parent::__construct($securityContext, $authenticationManager, $sessionStrategy, $httpUtils, $providerKey, $successHandler, $failureHandler, $options, $logger, $dispatcher);
}
/**
@@ -32,7 +32,6 @@ framework:
session:
storage_id: session.storage.mock_file
secret: %secret%
- charset: UTF-8
router: { resource: "%kernel.root_dir%/config/routing.yml" }
default_locale: %locale%
@@ -14,7 +14,8 @@ public function couldBeConstructedWithRequiredSetOfArguments()
$this->createSessionAuthenticationStrategyMock(),
$this->createHttpUtilsMock(),
'providerKey',
- $options = array()
+ $this->createAuthenticationSuccessHandlerMock(),
+ $this->createAuthenticationFailureHandlerMock(),
);
$this->getMockForAbstractClass(
@@ -34,7 +35,8 @@ public function shouldSetEmptyArrayAsRequiredAttributesOptionsInConstructor()
$this->createSessionAuthenticationStrategyMock(),
$this->createHttpUtilsMock(),
'providerKey',
- $options = array()
+ $this->createAuthenticationSuccessHandlerMock(),
+ $this->createAuthenticationFailureHandlerMock(),
);
$listener = $this->getMockForAbstractClass(
@@ -64,6 +66,8 @@ public function shouldSetCustomRequiredAttributesToOptionsInConstructor()
$this->createSessionAuthenticationStrategyMock(),
$this->createHttpUtilsMock(),
'providerKey',
+ $this->createAuthenticationSuccessHandlerMock(),
+ $this->createAuthenticationFailureHandlerMock(),
$options = array(
'required_attributes' => $expectedRequiredAttributes
)
@@ -91,6 +95,8 @@ public function shouldSetEmptyArrayAsOptionalAttributesOptionsInConstructor()
$this->createSessionAuthenticationStrategyMock(),
$this->createHttpUtilsMock(),
'providerKey',
+ $this->createAuthenticationSuccessHandlerMock(),
+ $this->createAuthenticationFailureHandlerMock(),
$options = array()
);
@@ -116,6 +122,8 @@ public function shouldAddOptionalAttributesToOptionsWithEmptyArrayAsDefaultValue
$this->createSessionAuthenticationStrategyMock(),
$this->createHttpUtilsMock(),
'providerKey',
+ $this->createAuthenticationSuccessHandlerMock(),
+ $this->createAuthenticationFailureHandlerMock(),
$options = array()
);
@@ -146,6 +154,8 @@ public function shouldSetCustomOptionalAttributesToOptionsInConstructor()
$this->createSessionAuthenticationStrategyMock(),
$this->createHttpUtilsMock(),
'providerKey',
+ $this->createAuthenticationSuccessHandlerMock(),
+ $this->createAuthenticationFailureHandlerMock(),
$options = array(
'optional_attributes' => $expectedOptionalAttributes
)
@@ -247,4 +257,14 @@ protected function createRelyingPartyMock()
{
return $this->getMock('Fp\OpenIdBundle\RelyingParty\RelyingPartyInterface');
}
+
+ protected function createAuthenticationSuccessHandlerMock()
+ {
+ return $this->getMock('Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface');
+ }
+
+ protected function createAuthenticationFailureHandlerMock()
+ {
+ return $this->getMock('Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface');
+ }
}
@@ -23,6 +23,8 @@ public function couldBeConstructedWithRequiredSetOfArguments()
$this->createSessionAuthenticationStrategyMock(),
$this->createHttpUtilsMock(),
'providerKey',
+ $this->createAuthenticationSuccessHandlerMock(),
+ $this->createAuthenticationFailureHandlerMock(),
$options = array()
);
}
@@ -51,6 +53,8 @@ public function shouldNotContinueAuthenticationIfCheckRequestPathReturnFalse()
$this->createSessionAuthenticationStrategyMock(),
$httpUtilsMock,
'providerKey',
+ $this->createAuthenticationSuccessHandlerMock(),
+ $this->createAuthenticationFailureHandlerMock(),
$options = array()
);
@@ -73,6 +77,8 @@ public function throwIfRelyingPartyNotSet()
$this->createSessionAuthenticationStrategyMock(),
$this->createHttpUtilsStub($checkRequestPathReturn = true),
'providerKey',
+ $this->createAuthenticationSuccessHandlerMock(),
+ $this->createAuthenticationFailureHandlerMock(),
$options = array()
);
@@ -103,6 +109,8 @@ public function shouldNotContinueAuthenticationIfRelyingPartySupportsReturnFalse
$this->createSessionAuthenticationStrategyMock(),
$this->createHttpUtilsStub($checkRequestPathReturn = true),
'providerKey',
+ $this->createAuthenticationSuccessHandlerMock(),
+ $this->createAuthenticationFailureHandlerMock(),
$options = array()
);
@@ -143,6 +151,8 @@ public function shouldDuplicateRequestAndPassItToRelyingPartyManageMethod()
$this->createSessionAuthenticationStrategyMock(),
$this->createHttpUtilsStub($checkRequestPathReturn = true),
'providerKey',
+ $this->createAuthenticationSuccessHandlerMock(),
+ $this->createAuthenticationFailureHandlerMock(),
$options = array()
);
@@ -183,6 +193,8 @@ public function shouldAddRequiredAttributesToDuplicatedRequest()
$this->createSessionAuthenticationStrategyMock(),
$this->createHttpUtilsStub($checkRequestPathReturn = true),
'providerKey',
+ $this->createAuthenticationSuccessHandlerMock(),
+ $this->createAuthenticationFailureHandlerMock(),
$options = array('required_attributes' => $expectedRequiredAttributes)
);
@@ -228,6 +240,8 @@ public function shouldAddOptionalAttributesToDuplicatedRequest()
$this->createSessionAuthenticationStrategyMock(),
$this->createHttpUtilsStub($checkRequestPathReturn = true),
'providerKey',
+ $this->createAuthenticationSuccessHandlerMock(),
+ $this->createAuthenticationFailureHandlerMock(),
$options = array('optional_attributes' => $expectedOptionalAttributes)
);
@@ -269,6 +283,8 @@ public function shouldSetRelyingPartyRedirectResponseToEvent()
$this->createSessionAuthenticationStrategyMock(),
$this->createHttpUtilsStub($checkRequestPathReturn = true),
'providerKey',
+ $this->createAuthenticationSuccessHandlerMock(),
+ $this->createAuthenticationFailureHandlerMock(),
$options = array()
);
@@ -301,6 +317,8 @@ public function throwIfRelyingPartyReturnNeitherRedirectResponseOrIdentityProvid
$this->createSessionAuthenticationStrategyMock(),
$this->createHttpUtilsStub($checkRequestPathReturn = true),
'providerKey',
+ $this->createAuthenticationSuccessHandlerMock(),
+ $this->createAuthenticationFailureHandlerMock(),
$options = array()
);
@@ -356,9 +374,9 @@ public function shouldAddIdentityProviderResponseToEachThrownAuthenticationExcep
$this->createSessionAuthenticationStrategyMock(),
$this->createHttpUtilsStub($checkRequestPathReturn = true),
'providerKey',
- $options = array(),
- null,
- $authenticationFailureHandlerMock
+ $this->createAuthenticationSuccessHandlerMock(),
+ $authenticationFailureHandlerMock,
+ $options = array()
);
$listener->setRelyingParty($relyingPartyMock);
@@ -416,6 +434,8 @@ public function shouldCreateOpenIdTokenUsingIdentityProviderResponseAndPassItToA
$this->createSessionAuthenticationStrategyMock(),
$httpUtilsStub,
'providerKey',
+ $this->createAuthenticationSuccessHandlerStub(),
+ $this->createAuthenticationFailureHandlerMock(),
$options = array()
);
@@ -470,6 +490,8 @@ public function shouldAddOpenIdTokenToSecurityContextIfSuccessfullyAuthenticated
$this->createSessionAuthenticationStrategyMock(),
$httpUtilsStub,
'providerKey',
+ $this->createAuthenticationSuccessHandlerStub(),
+ $this->createAuthenticationFailureHandlerMock(),
$options = array()
);
@@ -602,4 +624,22 @@ protected function createGetResponseEventStub($request = null)
return $getResponseEventMock;
}
+
+ protected function createAuthenticationSuccessHandlerMock()
+ {
+ return $this->getMock('Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface');
+ }
+
+ protected function createAuthenticationSuccessHandlerStub()
+ {
+ $handlerMock = $this->createAuthenticationSuccessHandlerMock();
+
+ $handlerMock
+ ->expects($this->any())
+ ->method('onAuthenticationSuccess')
+ ->will($this->returnValue(new Response()))
+ ;
+
+ return $handlerMock;
+ }
}
View
@@ -24,6 +24,7 @@
"psr-0": { "Fp\\OpenIdBundle": "" }
},
"target-dir": "Fp/OpenIdBundle",
+ "minimum-stability": "dev",
"extra": {
"branch-alias": {
"dev-master": "1.3-dev"

0 comments on commit a32a2e0

Please sign in to comment.