fix deprecations (move same controller) (#2440)
This commit is contained in:
@@ -23,6 +23,13 @@ class SystemConfiguration implements SystemBundleConfiguration
|
||||
return $repository->getConfiguration();
|
||||
}
|
||||
|
||||
// ========== SAML configurations ==========
|
||||
|
||||
public function isSamlActive(): bool
|
||||
{
|
||||
return (bool) $this->find('saml.activate');
|
||||
}
|
||||
|
||||
// ========== Calendar configurations ==========
|
||||
|
||||
public function getCalendarBusinessDays(): array
|
||||
|
||||
@@ -7,8 +7,9 @@
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace App\Saml\Controller;
|
||||
namespace App\Controller\Auth;
|
||||
|
||||
use App\Configuration\SystemConfiguration;
|
||||
use App\Saml\SamlAuth;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
@@ -21,14 +22,13 @@ use Symfony\Component\Security\Core\Security;
|
||||
*/
|
||||
final class SamlController extends AbstractController
|
||||
{
|
||||
/**
|
||||
* @var SamlAuth
|
||||
*/
|
||||
private $oneLoginAuth;
|
||||
private $systemConfiguration;
|
||||
|
||||
public function __construct(SamlAuth $oneLoginAuth)
|
||||
public function __construct(SamlAuth $oneLoginAuth, SystemConfiguration $systemConfiguration)
|
||||
{
|
||||
$this->oneLoginAuth = $oneLoginAuth;
|
||||
$this->systemConfiguration = $systemConfiguration;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -36,6 +36,10 @@ final class SamlController extends AbstractController
|
||||
*/
|
||||
public function loginAction(Request $request)
|
||||
{
|
||||
if (!$this->systemConfiguration->isSamlActive()) {
|
||||
throw $this->createNotFoundException('SAML deactivated');
|
||||
}
|
||||
|
||||
$session = $request->getSession();
|
||||
$authErrorKey = Security::AUTHENTICATION_ERROR;
|
||||
|
||||
@@ -60,6 +64,10 @@ final class SamlController extends AbstractController
|
||||
*/
|
||||
public function metadataAction()
|
||||
{
|
||||
if (!$this->systemConfiguration->isSamlActive()) {
|
||||
throw $this->createNotFoundException('SAML deactivated');
|
||||
}
|
||||
|
||||
$metadata = $this->oneLoginAuth->getSettings()->getSPMetadata();
|
||||
|
||||
$response = new Response($metadata);
|
||||
@@ -73,6 +81,10 @@ final class SamlController extends AbstractController
|
||||
*/
|
||||
public function assertionConsumerServiceAction()
|
||||
{
|
||||
if (!$this->systemConfiguration->isSamlActive()) {
|
||||
throw $this->createNotFoundException('SAML deactivated');
|
||||
}
|
||||
|
||||
throw new \RuntimeException('You must configure the check path in your firewall.');
|
||||
}
|
||||
|
||||
@@ -81,6 +93,10 @@ final class SamlController extends AbstractController
|
||||
*/
|
||||
public function logoutAction()
|
||||
{
|
||||
if (!$this->systemConfiguration->isSamlActive()) {
|
||||
throw $this->createNotFoundException('SAML deactivated');
|
||||
}
|
||||
|
||||
throw new \RuntimeException('You must configure the logout path in your firewall.');
|
||||
}
|
||||
}
|
||||
@@ -115,15 +115,13 @@ class Kernel extends BaseKernel
|
||||
yield new $class();
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// ... or we load them dynamically from the plugins directory
|
||||
foreach ($this->getBundleDirectories() as $bundleDir) {
|
||||
$bundleName = $bundleDir->getRelativePathname();
|
||||
$pluginClass = 'KimaiPlugin\\' . $bundleName . '\\' . $bundleName;
|
||||
yield new $pluginClass();
|
||||
} else {
|
||||
// ... or we load them dynamically from the plugins directory
|
||||
foreach ($this->getBundleDirectories() as $bundleDir) {
|
||||
$bundleName = $bundleDir->getRelativePathname();
|
||||
$pluginClass = 'KimaiPlugin\\' . $bundleName . '\\' . $bundleName;
|
||||
yield new $pluginClass();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -209,7 +207,6 @@ class Kernel extends BaseKernel
|
||||
|
||||
// some routes are based on app configs and will be imported manually
|
||||
$this->configureFosUserRoutes($routes);
|
||||
$this->configureSamlRoutes($routes);
|
||||
|
||||
// load bundle specific route files
|
||||
if (is_dir($confDir . '/routes/')) {
|
||||
@@ -251,15 +248,4 @@ class Kernel extends BaseKernel
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
protected function configureSamlRoutes(RouteCollectionBuilder $routes)
|
||||
{
|
||||
$saml = $this->getContainer()->getParameter('kimai.saml');
|
||||
|
||||
if (!$saml['activate']) {
|
||||
return;
|
||||
}
|
||||
|
||||
$routes->import('../src/Saml/Controller/SamlController.php', '/auth', 'annotation');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user