dingo / api

A RESTful API package for the Laravel and Lumen frameworks.
BSD 3-Clause "New" or "Revised" License
9.33k stars 1.25k forks source link

Prefered auth extention method in Dingo ? Guard, middleware, api.auth etc. #1535

Open jonaholsson opened 6 years ago

jonaholsson commented 6 years ago
Q A
Bug? no
New Feature? no
Framework Lumen
Framework version 5.6.5
Package version 2.0.0-alpha2
PHP version 7.1.14

Question

What is the prefered way of implementing custom authentication providers in Dingo v2 with Lumen?

I'm currently extending Dingo\Api\Auth\Auth in app.php to support Auth0 (https://auth0.com) like this:

app('Dingo\Api\Auth\Auth')->extend('auth0', function ($app) {
    return new \App\Providers\Auth0ServiceProvider;
});

However, I would like to support multiple authentication providers in the future and I find above method a bit static.

I'm looking into using the api.auth routing middleware with configuration files, but there are other options as well.

Can anyone point in the direction of a fresh example or provide some recommendations?