I have a external application that makes requests for content in my Drupal 8 instance. What I want to do is to make sure Drupal is only talking go my external application to stop traffic being spoofed.

I want to create a username and password for this application and have it add the credentials to the request like this https://username:password@test.local.com

How would I use the basic authentication module to check is the request has the username and password added and then authenticate the request and then send the response as needed?

  • If you are using a custom route you have to add requirements: _method: 'GET' _permission: 'access foo' _user_is_logged_in: 'TRUE' options: _auth: ['basic_auth', 'cookie']. Otherwise your question is too brought to answer. – user21641 Jul 9 '17 at 14:18
  • I have used basic authentication on custom routes but I need to have it optional on all routes. So if there is no authentication then render as normal but if there are basic authentication credentials added then run extra custom functionality. – harnamc Jul 9 '17 at 20:24

Your Answer

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

Browse other questions tagged or ask your own question.