I am completely struggling to get a custom bundle in Pimcore working as expected. I have a controller in this bundle that must be secured by a token authentication (like a Bearer token). This is my security.yml in BUNDLE_DIR/Resources/config/security.yml:
security:
providers:
noop_user_provider:
id: MyVendorPimcoreApiBundleSecurityNoopUserProvider
firewalls:
api:
pattern: ^/api
stateless: true
guard:
authenticators:
- MyVendorPimcoreApiBundleSecurityTokenAuthenticator
access_control:
- { path: ^/api, roles: IS_AUTHENTICATED_FULLY }
My controller route is as follows (via annotations):
/**
* @param string $id
* @return JsonResponse
* @Route("/api/read/{id}", name="myvendor_pimcore_api_read", methods={"GET"})
*/
public function read(string $id): JsonResponse
{
return $this->json([
'message' => 'Hello from your custom API! You ID was: '.$id,
]);
}
And my services.yml (directory: BUNDLE_DIR/Resources/config/services.yml) has the following entry:
MyVendorPimcoreApiBundleSecurityTokenAuthenticator:
arguments:
$validToken: 'sampleToken123'
tags:
- { name: security.guard_authenticator }
And whatever I tried, I cannot get it to work. If I try to include my security.yml via DependencyInjection, I get an error:
public function load(array $configs, ContainerBuilder $container): void
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
$loader = new LoaderYamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.yml');
$loader->load('security.yaml');
}
I get this error: There is no extension able to load the configuration for “security” (in “/var/www/html/bundles/MyVendor/PimcoreApiBundle/DependencyInjection/../Resources/config/security.yaml”). Looked for namespace “security”, found “none”.
I also tried multiple other things, which all resulted in more or less the same issue. Can someone help me here? I just want to my controller to be secured…