cartalyst / sentinel

A framework agnostic authentication & authorization system.
BSD 3-Clause "New" or "Revised" License
1.51k stars 238 forks source link

Using Sentinel statelessly without starting session #548

Open MirazMac opened 3 years ago

MirazMac commented 3 years ago

Your Environment

Expected behaviour

I'm using sentinel via the Native Facade. My app is an API thus it doesn't start a session. And sentinel shouldn't start one as well for stateless authentications.

Actual behaviour

Whenever I call any method via the Native Facade, it automatically starts a PHP session. Since my app is stateless, I don't want to start a session. Even calling Sentinel::stateless(); starts a session.

Is there any way I can use Sentinel statelessly without PHP session?

brunogaspar commented 3 years ago

Hey

It's creating a session because the native implementation do so require it.

I understand it might be undesirable that calling the stateless() method to create a session, but at the moment, with this code, that's not possible to do.

Unsure if there's a way, without many changes to the current native implementation, to achieve this, otherwise, you can just create your StatelessSession class and instruct Sentinel to use it perhaps. Just an idea.

@suwardany Any other ideas?

MirazMac commented 3 years ago

Hey

It's creating a session because the native implementation do so require it.

I understand it might be undesirable that calling the stateless() method to create a session, but at the moment, with this code, that's not possible to do.

Unsure if there's a way, without many changes to the current native implementation, to achieve this, otherwise, you can just create your StatelessSession class and instruct Sentinel to use it perhaps. Just an idea.

@suwardany Any other ideas?

Thanks for the response. Any idea how can I set my own Session handler to Sentinel? I don't see it in the docs. Thanks!

sawirricardo commented 3 years ago

Hi, any updates on this? I also am inteerested with this.