我对Symfony和oauth身份验证不是很自信...
我们有一个具有标准登录名的Web应用程序,该应用程序可以按预期运行。 现在,我们正在尝试为使用智能卡的用户提供一种并行身份验证方式。 我能够读取智能卡,但无法使用oauth请求来检索访问权限并刷新令牌。
我的想法是使用这些数据进行身份验证(均保存在用户表中):
那么,如何使用此数据检索有效的访问并刷新令牌?
在这种情况下正确的grant_type是什么,还需要其他什么参数?
这是我的代码:
$token = new UsernamePasswordToken($user, $smartCardSignature, 'main', $user->getRoles());
$user = $token->getUser();
$arrayOauthCredentials = array(
"client_id" => $client_id,
"client_secret" => $client_secret,
"grant_type" => "password",
"username" => // ?????
"password" => // ?????
);
$oAuth2GetAccessTokenReq = $this->oAuth2HttpClient->createRequest("POST", $this->getOAuth2Endpoint(self::TOKEN_ACTION), null, $arrayOauthCredentials);
$oAuth2Response = $this->oAuth2HttpClient->send($oAuth2GetAccessTokenReq);
$oAuth2 = json_decode($oAuth2Response->getBody(true));
$accessToken = $oAuth2->access_token;
$refreshToken = $oAuth2->refresh_token;
$session = $request->getSession();
if ($session->has("r_t"))
$session->remove("r_t");
$session->set("r_t", $refreshToken);
$user->setOAuth2Token($accessToken);
$this->em->persist($user);
$this->em->flush($user);
$this->get('security.token_storage')->setToken($token);
谢谢大家