Reputation: 6042
I'm attempting to test and debug a Symfony web app. When viewing the site using the app_dev.php
front controller/environment, the web debug toolbar doesn't load, and when I click on 'Open the web profiler', I get the following error:
Token "XXXXX" was not found in the database
*Note: it's not the literal value of XXXXX, but that the token it's looking for changes every time I try to open the profiler.
I also cannot log into the administration area of the site, likely because of this token error.
I think it may be an issue with how my security.yml
is set up, but nothing jumps out at me. Here it is:
security:
encoders:
FOS\UserBundle\Model\UserInterface: bcrypt
role_hierarchy:
ROLE_ADMIN: ROLE_USER
ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]
# https://symfony.com/doc/current/security.html#b-configuring-how-users-are-loaded
providers:
fos_userbundle:
id: fos_user.user_provider.username
in_memory:
memory: ~
firewalls:
# disables authentication for assets and the profiler, adapt it according to your needs
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
main:
pattern:
form_login:
provider: fos_userbundle
csrf_token_generator: security.csrf.token_manager
logout: true
anonymous: true
access_control:
- { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/admin/, role: ROLE_ADMIN }
The associated snippet in config.yml
:
fos_user:
db_driver: orm
firewall_name: main
user_class: AppBundle\Entity\User
from_email:
address: [email protected]
sender_name: 'someplace'
And, for completeness' sake, the part that references the toolbar in config_dev.yml
:
framework:
router:
resource: '%kernel.project_dir%/app/config/routing_dev.yml'
strict_requirements: true
profiler: { only_exceptions: false }
web_profiler:
toolbar: true
intercept_redirects: false
Finally, given that FOSUserBundle is my user provider, I also executed bin/console doctrine:schema:update --force
, but the issue remains.
Upvotes: 1
Views: 3259
Reputation: 6042
Figured it out. It was a combination of an incompletely installed service having an entry in services.yml
, yet missing files, and the wrong permissions/ownership for my /var
directory. I have a separate linux user for all of my apps to emulate what's on the production server (each site gets its own PHP-FPM pool, and none have root or sudo privileges).
So, with that said, commenting out the incomplete service in services.yml
and running $ sudo chown -R siteuser:siteuser /path/to/this/site/project
did the trick.
Upvotes: 1