| | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.lang.Opt; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import cn.hutool.http.HttpRequest; |
| | | import cn.hutool.http.HttpResponse; |
| | | import com.baomidou.lock.annotation.Lock4j; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | @Slf4j |
| | | @Service |
| | | public class SysLoginService { |
| | | |
| | | @Value("${justauth.type.keycloak.server-url}") |
| | | private String keycloakServerUrl; |
| | | |
| | | @Value("${justauth.type.keycloak.realm}") |
| | | private String keycloakRealm; |
| | | |
| | | @Value("${user.password.maxRetryCount}") |
| | | private Integer maxRetryCount; |
| | |
| | | TenantHelper.clearDynamic(); |
| | | } |
| | | recordLogininfor(loginUser.getTenantId(), loginUser.getUsername(), Constants.LOGOUT, MessageUtils.message("user.logout.success")); |
| | | |
| | | // 新增Keycloak登出逻辑 |
| | | |
| | | Long userId = loginUser.getUserId(); |
| | | |
| | | SysSocialVo social = sysSocialService.selectByUserId(userId); |
| | | if (social == null) { |
| | | return; |
| | | } |
| | | |
| | | String logoutUrl = keycloakServerUrl + "/realms/" + keycloakRealm + "/protocol/openid-connect/logout"; |
| | | HttpRequest request = HttpRequest.get(logoutUrl) |
| | | .form("refresh_token", social.getRefreshToken()) |
| | | .form("id_token_hint", social.getIdToken()); |
| | | |
| | | |
| | | HttpResponse response = request.execute(); |
| | | if (response.isOk()) { |
| | | System.out.println("1234"); |
| | | } |
| | | |
| | | } catch (NotLoginException ignored) { |
| | | } finally { |
| | | try { |