Initial commit: CloudOps infrastructure platform
This commit is contained in:
@@ -0,0 +1,110 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'routes' => [
|
||||
'public' => [
|
||||
// OAuth2
|
||||
'fos_oauth_server_token' => [
|
||||
'path' => '/oauth/v2/token',
|
||||
'controller' => 'fos_oauth_server.controller.token::tokenAction',
|
||||
'method' => 'GET|POST',
|
||||
],
|
||||
'fos_oauth_server_authorize' => [
|
||||
'path' => '/oauth/v2/authorize',
|
||||
'controller' => 'Mautic\ApiBundle\Controller\oAuth2\AuthorizeController::authorizeAction',
|
||||
'method' => 'GET|POST',
|
||||
],
|
||||
'mautic_oauth2_server_auth_login' => [
|
||||
'path' => '/oauth/v2/authorize_login',
|
||||
'controller' => 'Mautic\ApiBundle\Controller\oAuth2\SecurityController::loginAction',
|
||||
'method' => 'GET|POST',
|
||||
],
|
||||
'mautic_oauth2_server_auth_login_check' => [
|
||||
'path' => '/oauth/v2/authorize_login_check',
|
||||
'controller' => 'Mautic\ApiBundle\Controller\oAuth2\SecurityController::loginCheckAction',
|
||||
'method' => 'GET|POST',
|
||||
],
|
||||
],
|
||||
'main' => [
|
||||
// Clients
|
||||
'mautic_client_index' => [
|
||||
'path' => '/credentials/{page}',
|
||||
'controller' => 'Mautic\ApiBundle\Controller\ClientController::indexAction',
|
||||
],
|
||||
'mautic_client_action' => [
|
||||
'path' => '/credentials/{objectAction}/{objectId}',
|
||||
'controller' => 'Mautic\ApiBundle\Controller\ClientController::executeAction',
|
||||
],
|
||||
],
|
||||
],
|
||||
|
||||
'menu' => [
|
||||
'admin' => [
|
||||
'items' => [
|
||||
'mautic.api.client.menu.index' => [
|
||||
'route' => 'mautic_client_index',
|
||||
'access' => 'api:clients:view',
|
||||
'parent' => 'mautic.core.integrations',
|
||||
'iconClass' => 'ri-terminal-box-line',
|
||||
'priority' => 17,
|
||||
'checks' => [
|
||||
'parameters' => [
|
||||
'api_enabled' => true,
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
|
||||
'services' => [
|
||||
'helpers' => [
|
||||
'mautic.api.helper.entity_result' => [
|
||||
'class' => Mautic\ApiBundle\Helper\EntityResultHelper::class,
|
||||
],
|
||||
],
|
||||
'other' => [
|
||||
'mautic.api.oauth.event_listener' => [
|
||||
'class' => Mautic\ApiBundle\EventListener\PreAuthorizationEventListener::class,
|
||||
'arguments' => [
|
||||
'doctrine.orm.entity_manager',
|
||||
'mautic.security',
|
||||
'translator',
|
||||
],
|
||||
'tags' => [
|
||||
'kernel.event_listener',
|
||||
'kernel.event_listener',
|
||||
],
|
||||
'tagArguments' => [
|
||||
[
|
||||
'event' => 'fos_oauth_server.pre_authorization_process',
|
||||
'method' => 'onPreAuthorizationProcess',
|
||||
],
|
||||
[
|
||||
'event' => 'fos_oauth_server.post_authorization_process',
|
||||
'method' => 'onPostAuthorizationProcess',
|
||||
],
|
||||
],
|
||||
],
|
||||
'mautic.validator.oauthcallback' => [
|
||||
'class' => Mautic\ApiBundle\Form\Validator\Constraints\OAuthCallbackValidator::class,
|
||||
'tag' => 'validator.constraint_validator',
|
||||
],
|
||||
'mautic.api.security.voter.permission' => [
|
||||
'class' => Mautic\ApiBundle\Security\Voter\ApiPermissionVoter::class,
|
||||
'arguments' => [
|
||||
'mautic.security',
|
||||
],
|
||||
'tag' => 'security.voter',
|
||||
],
|
||||
],
|
||||
],
|
||||
|
||||
'parameters' => [
|
||||
'api_enabled' => false,
|
||||
'api_enable_basic_auth' => false,
|
||||
'api_oauth2_access_token_lifetime' => 60,
|
||||
'api_oauth2_refresh_token_lifetime' => 14,
|
||||
'api_batch_max_limit' => 200,
|
||||
],
|
||||
];
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use FOS\OAuthServerBundle\Form\Handler\AuthorizeFormHandler;
|
||||
use Mautic\CoreBundle\DependencyInjection\MauticCoreExtension;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
use function Symfony\Component\DependencyInjection\Loader\Configurator\service;
|
||||
|
||||
return function (ContainerConfigurator $configurator): void {
|
||||
$services = $configurator->services()
|
||||
->defaults()
|
||||
->autowire()
|
||||
->autoconfigure()
|
||||
->public();
|
||||
|
||||
$excludes = [
|
||||
'Serializer/Exclusion',
|
||||
'Helper/BatchIdToEntityHelper.php',
|
||||
];
|
||||
|
||||
$services->load('Mautic\\ApiBundle\\', '../')
|
||||
->exclude('../{'.implode(',', array_merge(MauticCoreExtension::DEFAULT_EXCLUDES, $excludes)).'}');
|
||||
|
||||
$services->load('Mautic\\ApiBundle\\Entity\\oAuth2\\', '../Entity/oAuth2/*Repository.php');
|
||||
|
||||
$services->alias(AuthorizeFormHandler::class, 'fos_oauth_server.authorize.form.handler.default');
|
||||
|
||||
$services->get(Mautic\ApiBundle\Controller\oAuth2\AuthorizeController::class)
|
||||
->arg('$authorizeForm', service('fos_oauth_server.authorize.form'))
|
||||
->arg('$oAuth2Server', service('fos_oauth_server.server'))
|
||||
->arg('$clientManager', service('fos_oauth_server.client_manager.default'))
|
||||
->tag('controller.service_arguments');
|
||||
|
||||
$services->alias('mautic.api.model.client', Mautic\ApiBundle\Model\ClientModel::class);
|
||||
|
||||
// Register custom PUT processor to fix PUT operations globally
|
||||
// This ensures PUT requests update existing entities instead of creating new ones
|
||||
// This decorates the default persist processor so it applies to all entities automatically
|
||||
$services->set(Mautic\ApiBundle\State\PutProcessor::class)
|
||||
->decorate('api_platform.doctrine.orm.state.persist_processor')
|
||||
->args([
|
||||
service('.inner'),
|
||||
service('doctrine.orm.entity_manager'),
|
||||
]);
|
||||
};
|
||||
Reference in New Issue
Block a user