명백한 커다란 단점은 클라이언트 자격 증명이 JWT 토큰에 사용자 정보가없는 것처럼 보입니다. 이로 인해 요청에 대한 사용자 확인자가 request()->user()
에 대한 호출에 대해 null을 반환합니다. Laravel\Passport\Guards\TokenGuard::authenticateViaBearerToken
에서이 null
을 반환되었다
// If the access token is valid we will retrieve the user according to the user ID
// associated with the token. We will use the provider implementation which may
// be used to retrieve users from Eloquent. Next, we'll be ready to continue.
$user = $this->provider->retrieveById(
$psr->getAttribute('oauth_user_id')
);
$psr->getAttribute
을 추적하는 것은 League\OAuth2\Server\AuthorizationValidators\BearerTokenValidator::validateAuthorization
를 알려준 :
oauth_user_id
제외
토큰, $token
에 특허 청구 범위를 통해 올바르게 설정되고 있었다 속성 // Return the request with additional attributes
return $request
->withAttribute('oauth_access_token_id', $token->getClaim('jti'))
->withAttribute('oauth_client_id', $token->getClaim('aud'))
->withAttribute('oauth_user_id', $token->getClaim('sub'))
->withAttribute('oauth_scopes', $token->getClaim('scopes'));
모든 내 경우는 Lcobucci\JWT\Token
의 사례입니다. 따라서 클라이언트 자격 증명 미들웨어 만 사용하면 지정된 user_id
의 oauth 클라이언트를 사용하는 경우에도 단일 경로 집합을 갖는 좋은 해결책이 아닙니다.