1

I would like to use the basic authentication middleware from Laravel, except not use a database behind it.

By default, the auth.basic middleware will use the email column on the user record as the "username".

Is there a way to change this to the filesystem or something other so I can simply add a username and password in a file somewhere. I just need simply security and my data is in an Elasticsearch server so I have no need for a MySQL database behind Laravel.

https://laravel.com/docs/5.4/authentication#http-basic-authentication

Stephan-v
  • 19,255
  • 31
  • 115
  • 201

1 Answers1

1

Just create a new middleware. See https://laravel.com/docs/5.4/middleware#registering-middleware

Inside your custom middleware, you can use your own custom authentication classes, which includes file io.

Then, put your authenticated routes inside that custom middleware route group.

Rob W
  • 9,134
  • 1
  • 30
  • 50