Вход в Laravel с помощью JWTPhp

Кемеровские программисты php общаются здесь
Anonymous
Вход в Laravel с помощью JWT

Сообщение Anonymous »

Я отвечаю за обновление приложения Laravel 5 до последней версии L10. само приложение использует JWT из службы LDAP. Все работает как положено до уровня L7, но в L8 механизм входа не работает должным образом, при попытке входа он всегда перенаправляется обратно на страницу входа (в службе LDAP), конечно, учетные данные верны.
Вот код:

Код: Выделить всё

public function loginJwt(Request $request)
{
$secure_random_token = $request->input('validate');
$token = Cache::pull($secure_random_token);
if (!$token) {
throw new AuthenticationException('Validasi request gagal[2]: Token is gone');
}

try {
$payload = JWTAuth::setToken($token)->getPayload();
} catch (TokenExpiredException $e) {
abort(400, $e->getMessage());
} catch (Exception $e) {
abort(400, $e->getMessage());
}

// If the class is using the ThrottlesLogins trait, we can automatically throttle
// the login attempts for this application. We'll key this by the username and
// the IP address of the client making these requests into this application.
if ($this->hasTooManyLoginAttempts($request)) {
$this->fireLockoutEvent($request);

return $this->sendLockoutResponse($request);
}

if ($this->attemptJwtLogin($request, $token, $payload)) {
$this->_jwt_tmp = $token;
return $this->sendLoginResponse($request);
}
return view('auth.failed');
}
В журнале ПРЕДУПРЕЖДЕНИЕ:

Код: Выделить всё

[2023-05-08 14:01:12] local.WARNING: {"username":null,"jwtId":null,"path":"\/","input":[],"method":"GET","originator":["127.0.0.1"],"header":["authorization","cookie","accept"],"exception":{"class":"Illuminate\\Auth\\AuthenticationException","message":"Unauthenticated."}}
Но это ПРЕДУПРЕЖДЕНИЕ существовало и в старой версии. Что может пойти не так?

Подробнее здесь: https://stackoverflow.com/questions/761 ... -using-jwt

Вернуться в «Php»