I'm having a hard time trying to figure out why my custom route is returning a 403 status.

My routing.yml file:

  path: '/lightbox/content'
    _controller: '\Drupal\lightbox\Controller\LightboxController::content'
    _title: 'Hello World'
      _permission: 'access content'
      _access: true

My permissions.yml file

access content:
  title: 'Access Content'
  description: 'Read all content'

Permission page: headers

screenshot from permissions

  • 1
    Is requirements really indented like that? Should be the same level as defaults. – Kevin Oct 13 '17 at 2:21
  • I feel dumb, that was my issue. – Pream Totaram Oct 13 '17 at 2:28
  • It happens. Look into using a YAML linter (online or offline) it will help out a lot. – Kevin Oct 13 '17 at 2:33

The issue, as mentioned in the comment was my indentation. I will leave this for anyone that may run into this issue.

  • 2
    One more, access content permission was existed, don't need define. And _access: true don't need _permission. – Jonh Oct 13 '17 at 2:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.