How to do Auth in Laravel without passwords?

Viewed 47

I am really struggling with Laravel auth. I read the manual many times, went to the code, but I still don't understand how the level of intrication of the Auth module.

As far as I understood, the app files that take part of the Auth are:

  • Manager: Auth (Illuminate\Auth\AuthManager)
  • Service Provider: AuthServiceProvider (Illuinate\Foundation\Support\ProvidersAuthServiceProvider)
  • Middleware: Authenticate
  • Gate
  • Model: User
  • Controller: LoginController

It seems these controllers LoginController, RegisterController, ... are called by magic, hardcoded deep down in Illuminate\Routing\Router. But, I do not want to use or register any ResetPasswordController, neither ForgotPasswordController simply because I do not hold any passwords on my application.

So in my case I do no store any email or password in my database. My authentication is done with OAuth2, the only think I do, is collecting an access token that I store on my database.

The question is:

How can I use the builtin Laravel Auth system that I am forced to use anyway because some providers require an access to app('auth')?

What then is the best solution in my case?

  1. Rewrite the whole Auth Manager and override the Router to remove the burred links to the unneeded controllers
  2. Tweak the existing Auth system to fulfill my needs

I am quite lost...

0 Answers
Related