Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

does it work with auth0? #188

Open
oriana-zippin opened this issue Jan 30, 2024 · 2 comments
Open

does it work with auth0? #188

oriana-zippin opened this issue Jan 30, 2024 · 2 comments

Comments

@oriana-zippin
Copy link

Hi, I'm trying to make some upgrades usign auth0 7.12 and impersonate, and trying to use the auth0 guard but I'm getting this error:
Call to undefined method Auth0\Laravel\Guards\AuthenticationGuard::quietLogin()

Before that I was using impersonate with the web guard and worked fine.

Is there a way I can use auth0 with this package?

@jose123v
Copy link

You have to extend auth0 guard and replace it, on you custom auth0 guard you have to implement quietLogin and quietLogout logic.

class SessionGuard extends BaseSessionGuard
{
/**
* Log a user into the application without firing the Login event.
*
* @param \Illuminate\Contracts\Auth\Authenticatable $user
* @return void
*/
public function quietLogin(Authenticatable $user)
{
$this->updateSession($user->getAuthIdentifier());
$this->setUser($user);
}
/**
* Logout the user without updating remember_token
* and without firing the Logout event.
*
* @param void
* @return void
*/
public function quietLogout()
{
$this->clearUserDataFromStorage();
$this->user = null;
$this->loggedOut = true;
}
}

$auth->extend('session', function (Application $app, $name, array $config) use ($auth) {
$provider = $auth->createUserProvider($config['provider']);
$guard = new SessionGuard($name, $provider, $app['session.store']);

@ComputerTinker
Copy link

Good afternoon. I'm running into an issue getting Auth0 and Laravel-impersonate working together as well, although for me the only error I see in my logs is Unauthenticated. which looks as though it's being thrown by vendor/laravel/framework/src/Illuminate/Auth/Middleware/Authenticate.php

@jose123v your idea of extending the Auth0 guard sounds promising, but unfortunately their AuthenticationGuard is defined as final class AuthenticationGuard extends GuardAbstract implements AuthenticationGuardContract, and because of the "final" it cannot be extended.

Is there a different way to go about this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants