Prestashop. How can allow anonymous users accses to custom symfony controller?

240 Views Asked by At

I have some question

What are you thinking, is it possible to use custom Symfony route without authorization I have custom additional Entity (in module) and need response JSON content for anonymous users (API)

But when I try to allow a route for anonymous users it requires authorization

security:
  providers:
    in_memory:
      memory: ~
    admin:
      id: prestashop.security.admin.provider

  firewalls:
    dev:
      pattern: ^/(_(profiler|wdt)|css|images|js)/
      security: false

    main:
      anonymous: true
      logout_on_user_change: true
  #    setting for public api visix
  access_control:
    - { path: '/visix/api', roles: IS_AUTHENTICATED_ANONYMOUSLY }

it working only with admin folder in url /adminxxx/visix/

#it working only with admin folder in url /adminxxx//visix/...
visix_module:
    resource: 'visix/routing.yml'
    prefix: /visix

#visix/routing.yml
visix_privat_api:
  path: /api
  methods: [GET]
  defaults:
    _controller: 'Visix\Controllers\Admin\SettingsConfiguratorController::getContent'
1

There are 1 best solutions below

0
Levente Kóré On

My opinion is that an easier and better solution is to use a custom FrontController to your modul, and write the API logic in that controller.