1 | <?php |
||
19 | abstract class BaseGuard |
||
20 | implements GaurdContract |
||
|
|||
21 | { |
||
22 | use GuardHelpers; |
||
23 | |||
24 | const JWT_GUARD_CLAIM = 'grd'; |
||
25 | |||
26 | /** |
||
27 | * @var string |
||
28 | */ |
||
29 | protected $id; |
||
30 | |||
31 | /** |
||
32 | * @var Request |
||
33 | */ |
||
34 | protected $request; |
||
35 | |||
36 | /** |
||
37 | * @var array |
||
38 | */ |
||
39 | protected $config; |
||
40 | |||
41 | /** |
||
42 | * @var array |
||
43 | */ |
||
44 | private $factoryCache = []; |
||
45 | |||
46 | /** |
||
47 | * Constructor |
||
48 | * |
||
49 | * @param UserProvider $provider |
||
50 | * @param Request $request |
||
51 | */ |
||
52 | 25 | public function __construct($id, UserProvider $provider, Request $request, array $config = []) |
|
59 | |||
60 | /** |
||
61 | * Returns the adapter class name to use |
||
62 | * |
||
63 | * @return string |
||
64 | */ |
||
65 | 16 | public function getAdapterFactoryClass() |
|
81 | |||
82 | /** |
||
83 | * Returns the adapter factory object |
||
84 | * |
||
85 | * @return AdapterFactoryContract |
||
86 | */ |
||
87 | 16 | protected function getAdapterFactory() |
|
99 | |||
100 | /** |
||
101 | * Returns a token processor from the adapter factory |
||
102 | * |
||
103 | * @return ProcessorContract |
||
104 | */ |
||
105 | 11 | protected function getProcessor() |
|
109 | |||
110 | /** |
||
111 | * Returns a token generator from the adapter factory |
||
112 | * |
||
113 | * @return GeneratorContract |
||
114 | */ |
||
115 | 8 | protected function getGenerator() |
|
119 | |||
120 | /** |
||
121 | * Gets the provider |
||
122 | * |
||
123 | * @return UserProvider |
||
124 | */ |
||
125 | 15 | public function getProvider() |
|
129 | |||
130 | /** |
||
131 | * @inheritdoc |
||
132 | */ |
||
133 | 7 | public function user() |
|
150 | |||
151 | /** |
||
152 | * @inheritdoc |
||
153 | */ |
||
154 | 13 | public function getBearerToken($isRefresh = false) |
|
163 | |||
164 | /** |
||
165 | * @inheritdoc |
||
166 | */ |
||
167 | 2 | public function validate(array $credentials = []) |
|
175 | |||
176 | /** |
||
177 | * Determine if the user matches the credentials. |
||
178 | * |
||
179 | * @param Authenticatable|null $user |
||
180 | * @param array $credentials |
||
181 | * @return bool |
||
182 | */ |
||
183 | 7 | protected function hasValidCredentials($user, $credentials) |
|
187 | |||
188 | /** |
||
189 | * Sets the Request |
||
190 | * |
||
191 | * @param Request $request |
||
192 | */ |
||
193 | 1 | public function setRequest(Request $request) |
|
197 | |||
198 | /** |
||
199 | * Gets the request |
||
200 | * |
||
201 | * @return Request |
||
202 | */ |
||
203 | 1 | public function getRequest() |
|
207 | |||
208 | /** |
||
209 | * Attempt to authenticate a user using the given credentials. |
||
210 | * |
||
211 | * @param array $credentials |
||
212 | * @param boolean $login |
||
213 | * @return bool|Token |
||
214 | */ |
||
215 | 5 | public function attempt(array $credentials = [], $login = true) |
|
229 | |||
230 | /** |
||
231 | * Log a user into the application. |
||
232 | * |
||
233 | * @param \Illuminate\Contracts\Auth\Authenticatable $user |
||
234 | */ |
||
235 | 6 | public function login(Authenticatable $user) |
|
240 | |||
241 | /** |
||
242 | * Clear user |
||
243 | * @return boolean |
||
244 | */ |
||
245 | 1 | public function logout() |
|
250 | |||
251 | /** |
||
252 | * Generate a new token |
||
253 | * |
||
254 | * @param SubjectContract $user |
||
255 | * @return Token |
||
256 | */ |
||
257 | 5 | protected function generateToken(SubjectContract $user) |
|
268 | } |
||
269 |