Pimcore/Symfony Bundle with custom token authentication for custom controller

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:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>security:
providers:
noop_user_provider:
id: MyVendorPimcoreApiBundleSecurityNoopUserProvider
firewalls:
api:
pattern: ^/api
stateless: true
guard:
authenticators:
- MyVendorPimcoreApiBundleSecurityTokenAuthenticator
access_control:
- { path: ^/api, roles: IS_AUTHENTICATED_FULLY }
</code>
<code>security: providers: noop_user_provider: id: MyVendorPimcoreApiBundleSecurityNoopUserProvider firewalls: api: pattern: ^/api stateless: true guard: authenticators: - MyVendorPimcoreApiBundleSecurityTokenAuthenticator access_control: - { path: ^/api, roles: IS_AUTHENTICATED_FULLY } </code>
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):

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>/**
* @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,
]);
}
</code>
<code>/** * @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, ]); } </code>
/**
 * @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:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code> MyVendorPimcoreApiBundleSecurityTokenAuthenticator:
arguments:
$validToken: 'sampleToken123'
tags:
- { name: security.guard_authenticator }
</code>
<code> MyVendorPimcoreApiBundleSecurityTokenAuthenticator: arguments: $validToken: 'sampleToken123' tags: - { name: security.guard_authenticator } </code>
    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:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>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');
}
</code>
<code>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'); } </code>
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…

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật