diff --git a/lib/SimpleSAML/Resources/config/services/simplesaml.xml b/lib/SimpleSAML/Resources/config/services/simplesaml.xml new file mode 100644 index 0000000000000000000000000000000000000000..ce6b47efa78a588aff9468b8c2c40fe0adabe672 --- /dev/null +++ b/lib/SimpleSAML/Resources/config/services/simplesaml.xml @@ -0,0 +1,22 @@ +<?xml version="1.0" ?> + +<container xmlns="http://symfony.com/schema/dic/services" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> + + <services> + <defaults public="false"/> + + <service id="SimpleSAML\Configuration"> + <factory class="SimpleSAML\Configuration" method="getInstance" /> + </service> + + <service id="SimpleSAML\Session"> + <factory class="SimpleSAML\Session" method="getSessionFromRequest" /> + </service> + + <service class="SimpleSAML\Auth\AuthenticationFactory"> + <argument type="service" id="SimpleSAML\Configuration"/> + </service> + </services> +</container> diff --git a/modules/core/routes.yaml b/modules/core/config/routes/routes.yaml similarity index 77% rename from modules/core/routes.yaml rename to modules/core/config/routes/routes.yaml index 80916d2ab51c7a39b650b5c841983f0ba4a629f2..70d69139583f9871d62d28f60bb7350041729cc5 100644 --- a/modules/core/routes.yaml +++ b/modules/core/config/routes/routes.yaml @@ -1,9 +1,9 @@ core-login: path: /login/{as} - defaults: { _controller: 'SimpleSAML\Module\core\Controller::login', as: null } + defaults: { _controller: 'SimpleSAML\Module\core\Controller\LoginController:login', as: null } core-account: path: /account/{as} - defaults: { _controller: 'SimpleSAML\Module\core\Controller::account' } + defaults: { _controller: 'SimpleSAML\Module\core\Controller\LoginController:account' } core-logout: path: /logout/{as} - defaults: { _controller: 'SimpleSAML\Module\core\Controller::logout' } + defaults: { _controller: 'SimpleSAML\Module\core\Controller\LoginController:logout' } diff --git a/modules/core/lib/Controller.php b/modules/core/lib/Controller/LoginController.php similarity index 98% rename from modules/core/lib/Controller.php rename to modules/core/lib/Controller/LoginController.php index a9737edb47cf44ab2cd0930f39cb743d5bddd3de..94f3e7928d5ba4ef5caf991fef44f7bca2339fe2 100644 --- a/modules/core/lib/Controller.php +++ b/modules/core/lib/Controller/LoginController.php @@ -1,6 +1,6 @@ <?php -namespace SimpleSAML\Module\core; +namespace SimpleSAML\Module\core\Controller; use SimpleSAML\Auth; use SimpleSAML\Auth\AuthenticationFactory; @@ -21,7 +21,7 @@ use Symfony\Component\HttpFoundation\Request; * * @package SimpleSAML\Module\core */ -class Controller +class LoginController { /** @var \SimpleSAML\Configuration */ protected $config; diff --git a/modules/core/templates/login.twig b/modules/core/templates/login.twig index be87ded7bfb26f9121b84bc8f88ae8c81ce99b97..2e60b4aa1a8573759674fecfd94a2daa50a3f10e 100644 --- a/modules/core/templates/login.twig +++ b/modules/core/templates/login.twig @@ -13,7 +13,7 @@ <ul class="pure-menu-list auth_methods"> {% for id, config in sources -%} <li class="pure-menu-item"> - <a href="/{{ baseurlpath }}module.php/core/login/{{ id|url_encode }}" class="pure-menu-link"> + <a href="{{ moduleURL('core/login/' ~ id|url_encode ) }}" class="pure-menu-link"> {{ config.name|translateFromArray|default(id) }} </a> </li> diff --git a/tests/modules/core/lib/ControllerTest.php b/tests/modules/core/lib/Controller/LoginControllerTest.php similarity index 92% rename from tests/modules/core/lib/ControllerTest.php rename to tests/modules/core/lib/Controller/LoginControllerTest.php index e3a239d42e1916ab2014aa8137fe5ad3f1aa64e2..9e7c99513e40b8529ff985256a8dd7b068a9a135 100644 --- a/tests/modules/core/lib/ControllerTest.php +++ b/tests/modules/core/lib/Controller/LoginControllerTest.php @@ -1,6 +1,6 @@ <?php -namespace SimpleSAML\Test\Module\core; +namespace SimpleSAML\Test\Module\core\Controller; use SimpleSAML\Auth\Simple; use SimpleSAML\Auth\AuthenticationFactory; @@ -8,7 +8,7 @@ use SimpleSAML\Configuration; use SimpleSAML\Error\Exception; use SimpleSAML\HTTP\RunnableResponse; use SimpleSAML\Locale\Localization; -use SimpleSAML\Module\core\Controller; +use SimpleSAML\Module\core\Controller\LoginController; use SimpleSAML\Session; use SimpleSAML\Test\Utils\ClearStateTestCase; use SimpleSAML\XHTML\Template; @@ -23,7 +23,7 @@ use Symfony\Component\HttpFoundation\Request; * * @package SimpleSAML\Test */ -class ControllerTest extends ClearStateTestCase +class LoginControllerTest extends ClearStateTestCase { /** @var array */ protected $authSources; @@ -34,10 +34,6 @@ class ControllerTest extends ClearStateTestCase /** @var \SimpleSAML\Configuration[] */ protected $loadedConfigs; - /** @var \SimpleSAML\HTTP\Router */ - protected $router; - - /** * Set up for each test. * @return void @@ -83,8 +79,8 @@ class ControllerTest extends ClearStateTestCase $session = Session::getSessionFromRequest(); $factory = new AuthenticationFactory($this->config, $session); - $c = new Controller($this->config, $session, $factory); /** @var \SimpleSAML\HTTP\RunnableResponse $response */ + $c = new LoginController($this->config, $session, $factory); $response = $c->login($request); $this->assertInstanceOf(RunnableResponse::class, $response); @@ -122,8 +118,8 @@ class ControllerTest extends ClearStateTestCase $session = Session::getSessionFromRequest(); $factory = new AuthenticationFactory($this->config, $session); - $c = new Controller($this->config, $session, $factory); /** @var \SimpleSAML\XHTML\Template $response */ + $c = new LoginController($this->config, $session, $factory); $response = $c->login($request); $this->assertInstanceOf(Template::class, $response); @@ -145,8 +141,8 @@ class ControllerTest extends ClearStateTestCase $request = new Request(); $session = Session::getSessionFromRequest(); $factory = new AuthenticationFactory($this->config, $session); - $c = new Controller($this->config, $session, $factory); - $this->expectException(Exception::class); + $c = new LoginController($this->config, $session, $factory); + $this->setExpectedException(Exception::class); $c->login($request, 'invalid-auth-source'); } @@ -178,10 +174,10 @@ class ControllerTest extends ClearStateTestCase ]); $factory = new AuthenticationFactory($this->config, $session); - $c = new Controller($this->config, $session, $factory); $request = new Request(); /** @var \Symfony\Component\HttpFoundation\RedirectResponse $response */ + $c = new LoginController($this->config, $session, $factory); $response = $c->login($request); $this->assertInstanceOf(RedirectResponse::class, $response); $this->assertEquals( @@ -201,7 +197,7 @@ class ControllerTest extends ClearStateTestCase Configuration::setPreLoadedConfig($asConfig, 'authsources.php'); $session = Session::getSessionFromRequest(); $factory = new AuthenticationFactory($this->config, $session); - $c = new Controller($this->config, $session, $factory); + $c = new LoginController($this->config, $session, $factory); $response = $c->logout('example-userpass'); $this->assertInstanceOf(RunnableResponse::class, $response); list($object, $method) = $response->getCallable(); @@ -222,7 +218,7 @@ class ControllerTest extends ClearStateTestCase Configuration::setPreLoadedConfig($asConfig, 'authsources.php'); $session = Session::getSessionFromRequest(); $factory = new AuthenticationFactory($this->config, $session); - $c = new Controller($this->config, $session, $factory); + $c = new LoginController($this->config, $session, $factory); /** @var RedirectResponse $response */ $response = $c->account('example-userpass'); $this->assertInstanceOf(RedirectResponse::class, $response); @@ -255,7 +251,7 @@ class ControllerTest extends ClearStateTestCase ] ]); $factory = new AuthenticationFactory($this->config, $session); - $c = new Controller($this->config, $session, $factory); + $c = new LoginController($this->config, $session, $factory); /** @var \SimpleSAML\XHTML\Template $response */ $response = $c->account('example-userpass'); $this->assertInstanceOf(Template::class, $response);