3 namespace BookStack\Auth\Access\Guards;
5 use BookStack\Auth\Access\OpenIdService;
6 use BookStack\Auth\Access\RegistrationService;
7 use Illuminate\Contracts\Auth\UserProvider;
8 use Illuminate\Contracts\Session\Session;
11 * OpenId Session Guard
13 * The OpenId login process is async in nature meaning it does not fit very well
14 * into the default laravel 'Guard' auth flow. Instead most of the logic is done
15 * via the OpenId controller & OpenIdService. This class provides a safer, thin
16 * version of SessionGuard.
18 * @package BookStack\Auth\Access\Guards
20 class OpenIdSessionGuard extends ExternalBaseSessionGuard
23 protected $openidService;
26 * OpenIdSessionGuard constructor.
28 public function __construct(
30 UserProvider $provider,
32 OpenIdService $openidService,
33 RegistrationService $registrationService
35 $this->openidService = $openidService;
36 parent::__construct($name, $provider, $session, $registrationService);
40 * Get the currently authenticated user.
42 * @return \Illuminate\Contracts\Auth\Authenticatable|null
44 public function user()
46 // retrieve the current user
47 $user = parent::user();
49 // refresh the current user
50 if ($user && !$this->openidService->refresh()) {
58 * Validate a user's credentials.
60 * @param array $credentials
63 public function validate(array $credentials = [])
69 * Attempt to authenticate a user using the given credentials.
71 * @param array $credentials
72 * @param bool $remember
75 public function attempt(array $credentials = [], $remember = false)