flat3 / lodata

The OData v4.01 Producer for Laravel
https://lodata.io/
MIT License
80 stars 26 forks source link

Autentication handle #482

Closed crisleiria closed 1 year ago

crisleiria commented 1 year ago

I have the following scenario:

As my understanding, the odata endpoint created with this package, do not work with laravel auth by default. So, the endpoint http://domain.com/odata/{Model} is public by default.

I want to protect this routes.

If I set middleware to 'auth:sanctum' as the docs recomend on config/lodata.php, I need to pass the user token on the headers.

I am using Inertia, with the default sanctum auth, thru cookies and not tokens. I do not have user token on client side to pass on the odata requests. So, I end up getting "Unauthorized" requests.

I have several options here...

I would like to have a more elegant way to do this.... Maybe someone have already this scenario?

Thanks in advance

27pchrisl commented 1 year ago

Is it enough to add a different set of middleware to Lodata's config, such as 'web' so that it picks up the cookie auth ?

crisleiria commented 1 year ago

Is it enough to add a different set of middleware to Lodata's config, such as 'web' so that it picks up the cookie auth ?

Yes, for this scenario its enough.