我有一个集成了IDP keycloak登录的系统。会话到期的空闲时间设置为20分钟。在这20分钟的空闲时间之后,用户的会话数据自动到期。但是现在我想要一个来自会话的数据从keycloak服务器中删除用户会话。我找不到任何方法来做到这一点。谁能给我一个好的解决方案来在空闲超时后从keycloak中注销用户吗?
$session_data = $this->session->userdata('logged_in');
$idp_data = $this->session->userdata('idp_token');
$ad_data['session_id']=$idp_data['session_state'];
$logdata=$this->key_logout($ad_data);
public function key_logout($ad_data)
{
/* keycloak */
/* Developer: Kowshiga A
Created at : 26.8.2021
Description: Logout session from IDP (Oauth flow)
*/
$key_token=$this->key_get_token();
$ad_data['add_token']=$key_token['access_token'];
$this->auth_token1 = 'Authorization: Bearer '.$ad_data['add_token'];
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => $this->keycloak_admin_url.'sessions/'.$ad_data['session_id'],
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_SSL_VERIFYPEER=> FALSE,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'DELETE',
CURLOPT_HTTPHEADER => array(
$this->auth_token1
),
));
$response = curl_exec($curl);
curl_close($curl);
//print_r($response);die;
return $response;
}
1条答案
按热度按时间eivnm1vs1#
会话到期后,用户将自动注销,您无需执行任何操作!