Initial commit: CloudOps infrastructure platform

This commit is contained in:
root
2026-04-09 19:58:57 +02:00
commit 1166a52f26
7762 changed files with 839452 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
<?php
declare(strict_types=1);
namespace Mautic\UserBundle\DependencyInjection\Compiler;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
class FormLoginAuthenticatorOptionsPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container): void
{
if (!$container->has('mautic.security.authenticator.form_login.decorator')) {
return;
}
$decoratedServiceId = 'mautic.security.authenticator.form_login.decorator.inner';
if (!$container->has($decoratedServiceId)) {
return;
}
$decoratedService = $container->getDefinition($decoratedServiceId);
// Grab the options from the original definition
$options = $decoratedService->getArgument(4);
$decorator = $container->getDefinition('mautic.security.authenticator.form_login.decorator');
// Set the options for our decorated service
$decorator->replaceArgument(3, $options);
}
}

View File

@@ -0,0 +1,22 @@
<?php
declare(strict_types=1);
namespace Mautic\UserBundle\DependencyInjection\Compiler;
use Mautic\UserBundle\Security\Authenticator\Oauth2Authenticator;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
class OAuthReplacePass implements CompilerPassInterface
{
public function process(ContainerBuilder $container): void
{
if (!$container->hasDefinition('fos_oauth_server.security.authenticator.manager')) {
return;
}
$oAuthAuthenticatorDefinition = $container->getDefinition('fos_oauth_server.security.authenticator.manager');
$oAuthAuthenticatorDefinition->setClass(Oauth2Authenticator::class);
}
}

View File

@@ -0,0 +1,40 @@
<?php
declare(strict_types=1);
namespace Mautic\UserBundle\DependencyInjection\Compiler;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
/**
* This will replace $options in the
* \Mautic\UserBundle\DependencyInjection\Firewall\Factory\MauticSsoFactory::createAuthenticator.
*/
class SsoAuthenticatorPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container): void
{
$ssoAuthenticatorId = 'security.authenticator.mautic_sso.main';
if (!$container->hasDefinition($ssoAuthenticatorId)) {
throw new ServiceNotFoundException($ssoAuthenticatorId);
}
$formLoginAuthenticatorId = 'security.authenticator.form_login.main';
if (!$container->hasDefinition($formLoginAuthenticatorId)) {
throw new ServiceNotFoundException($formLoginAuthenticatorId);
}
$loginFormAuthenticator = $container->getDefinition($formLoginAuthenticatorId);
$formLoginOptions = $loginFormAuthenticator->getArgument(4);
if (!is_array($formLoginOptions)) {
throw new InvalidArgumentException('The $options parameter must be an array. Maybe Symfony moved the parameter for the "form_login"?');
}
$container->getDefinition($ssoAuthenticatorId)
->replaceArgument('$options', $formLoginOptions);
}
}

View File

@@ -0,0 +1,86 @@
<?php
declare(strict_types=1);
namespace Mautic\UserBundle\DependencyInjection\Firewall\Factory;
use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\AbstractFactory;
use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\AuthenticatorFactoryInterface;
use Symfony\Component\DependencyInjection\ChildDefinition;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;
final class MauticSsoFactory extends AbstractFactory implements AuthenticatorFactoryInterface
{
/**
* Before form_login, otherwise the \Symfony\Component\Security\Http\Authenticator\FormLoginAuthenticator::supports
* of form_login will return true, and the authentication will be finished with an error.
* SSO Authenticator will be executed only if it has same options as form_login + request
* will have 'integration_parameter' in the Request.
*/
public const PRIORITY = -25;
public function __construct()
{
$this->addOption('username_parameter', '_username');
$this->addOption('password_parameter', '_password');
$this->addOption('integration_parameter', 'integration');
$this->addOption('csrf_parameter', '_csrf_token');
$this->addOption('csrf_token_id', 'authenticate');
$this->addOption('enable_csrf', true);
$this->addOption('post_only', true);
$this->addOption('form_only', false);
$this->addOption('login_path', '/s/login');
$this->addOption('check_path', '/s/login_check');
}
public function createAuthenticator(ContainerBuilder $container, string $firewallName, array $config, string $userProviderId): string
{
$authenticatorId = 'security.authenticator.mautic_sso.'.$firewallName;
// use same auth handlers as in login_form
$authenticationSuccessHandlerId = $this->getSuccessHandlerId($firewallName);
$formLoginSuccessHandlerId = str_replace('mautic_sso', 'form_login', $authenticationSuccessHandlerId);
$authenticationFailureHandlerId = $this->getFailureHandlerId($firewallName);
$formLoginFailureHandlerId = str_replace('mautic_sso', 'form_login', $authenticationFailureHandlerId);
$authenticator = $container
->setDefinition($authenticatorId, new ChildDefinition('security.authenticator.mautic_sso'))
->replaceArgument('$options', []) // Options will be replaced in \Mautic\UserBundle\DependencyInjection\Compiler\SsoAuthenticatorPass
->replaceArgument('$userProvider', new Reference($userProviderId))
->replaceArgument('$successHandler', new Reference($formLoginSuccessHandlerId))
->replaceArgument('$failureHandler', new Reference($formLoginFailureHandlerId));
$container->setDefinition($authenticatorId, $authenticator);
return $authenticatorId;
}
public function getKey(): string
{
return 'mautic-sso';
}
public function getPriority(): int
{
return self::PRIORITY;
}
public function getPosition(): string
{
return 'form';
}
/**
* @param array<mixed> $config
*/
protected function createAuthProvider(ContainerBuilder $container, string $id, array $config, string $userProviderId): string
{
throw new \Exception('The old authentication system is not supported with mautic-sso.');
}
protected function getListenerId(): string
{
throw new \Exception('The old authentication system is not supported with mautic-sso.');
}
}

View File

@@ -0,0 +1,42 @@
<?php
namespace Mautic\UserBundle\DependencyInjection\Firewall\Factory;
use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\AuthenticatorFactoryInterface;
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
use Symfony\Component\DependencyInjection\ChildDefinition;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;
class PluginFactory implements AuthenticatorFactoryInterface
{
public const PRIORITY = -30;
public function createAuthenticator(ContainerBuilder $container, string $firewallName, array $config, string $userProviderId): string
{
$authenticatorId = 'security.authentication.provider.mautic.'.$firewallName;
$authenticator = $container
->setDefinition($authenticatorId, new ChildDefinition('security.authenticator.mautic_api'))
->replaceArgument('$firewallName', $firewallName)
->replaceArgument('$userProvider', new Reference($userProviderId));
$container->setDefinition($authenticatorId, $authenticator);
return $authenticatorId;
}
public function getPriority(): int
{
return self::PRIORITY;
}
public function getKey(): string
{
return 'mautic_plugin_auth';
}
public function addConfiguration(NodeDefinition $node): void
{
}
}

View File

@@ -0,0 +1,28 @@
<?php
declare(strict_types=1);
namespace Mautic\UserBundle\DependencyInjection;
use Mautic\UserBundle\EventListener\SAMLSubscriber;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Extension\Extension;
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
class MauticUserExtension extends Extension
{
/**
* @param mixed[] $configs
*/
public function load(array $configs, ContainerBuilder $container): void
{
$loader = new PhpFileLoader($container, new FileLocator(__DIR__.'/../Config'));
$loader->load('services.php');
$samlEnabled = $container->getParameter('mautic.saml_enabled');
if (true !== $samlEnabled) {
$container->removeDefinition(SAMLSubscriber::class);
}
}
}