|
@@ -1,8 +1,8 @@
|
|
|
package org.maxkey.web.contorller;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.nimbusds.jwt.SignedJWT;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
-import org.apache.catalina.User;
|
|
|
import org.maxkey.authn.AbstractAuthenticationProvider;
|
|
|
import org.maxkey.authn.realm.jdbc.JdbcAuthenticationRealm;
|
|
|
import org.maxkey.authn.support.jwt.JwtLoginService;
|
|
@@ -10,6 +10,8 @@ import org.maxkey.authn.support.socialsignon.service.SocialSignOnProviderService
|
|
|
import org.maxkey.entity.Organizations;
|
|
|
import org.maxkey.entity.SocialsProvider;
|
|
|
import org.maxkey.entity.UserInfo;
|
|
|
+import org.maxkey.persistence.redis.RedisConnection;
|
|
|
+import org.maxkey.persistence.redis.RedisConnectionFactory;
|
|
|
import org.maxkey.persistence.service.OrganizationsService;
|
|
|
import org.maxkey.persistence.service.UserInfoService;
|
|
|
import org.maxkey.util.RetCode;
|
|
@@ -20,15 +22,15 @@ import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Qualifier;
|
|
|
-import org.springframework.stereotype.Controller;
|
|
|
+import org.springframework.data.redis.core.RedisTemplate;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import org.maxkey.util.RetResult;
|
|
|
-import org.springframework.web.servlet.ModelAndView;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
@RestController
|
|
|
@RequestMapping("/thirdLogin")
|
|
@@ -60,6 +62,9 @@ public class ThirdLoginController
|
|
|
SocialSignOnProviderService socialSignOnProviderService;
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
+ RedisConnectionFactory redisConnectionFactory;
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* init login
|
|
@@ -84,11 +89,16 @@ public class ThirdLoginController
|
|
|
String token = jwtLoginService.buildLoginJwt();
|
|
|
data.put("userInfo", userInfo);
|
|
|
data.put("token", token);
|
|
|
+ RedisConnection redisConnection = redisConnectionFactory.getConnection();
|
|
|
+ // 默认 30分钟
|
|
|
+ redisConnection.setex(token,1800,JSON.toJSONString(userInfo));
|
|
|
+ redisConnection.close();
|
|
|
_logger.debug("token >>>" + token);
|
|
|
result.setData(data);
|
|
|
result.setCode(RetCode.SUCCESS);
|
|
|
return result;
|
|
|
}
|
|
|
+
|
|
|
result = new RetResult();
|
|
|
result.setCode(RetCode.FAIL);
|
|
|
result.setMsg("用户不存在");
|
|
@@ -113,8 +123,9 @@ public class ThirdLoginController
|
|
|
return new RetResult().setMsg("token出错").setCode(RetCode.FAIL);
|
|
|
}
|
|
|
|
|
|
- @RequestMapping(value={"/usersList"})
|
|
|
- public RetResult usersList(){
|
|
|
+ @RequestMapping(value = {"/usersList"})
|
|
|
+ public RetResult usersList()
|
|
|
+ {
|
|
|
List<UserInfo> users = userInfoService.query(null);
|
|
|
|
|
|
return new RetResult().setMsg("请求成功").setData(users).setCode(RetCode.SUCCESS);
|
|
@@ -127,7 +138,7 @@ public class ThirdLoginController
|
|
|
* @return
|
|
|
*/
|
|
|
@GetMapping({"/organizationsTree"})
|
|
|
- public List<HashMap<String, Object>> organizationsTree(HttpServletRequest request,@RequestParam(value = "id", required = false) String id)
|
|
|
+ public List<HashMap<String, Object>> organizationsTree(HttpServletRequest request, @RequestParam(value = "id", required = false) String id)
|
|
|
{
|
|
|
String authorization = request.getHeader("Authorization");
|
|
|
_logger.debug("authorization id :" + authorization);
|
|
@@ -161,12 +172,13 @@ public class ThirdLoginController
|
|
|
|
|
|
|
|
|
/**
|
|
|
- * 获取第三方登录信息
|
|
|
- * dingtalk: /logon/oauth20/authorize/dingtalk
|
|
|
+ * 获取第三方登录信息
|
|
|
+ * dingtalk: /logon/oauth20/authorize/dingtalk
|
|
|
*/
|
|
|
@GetMapping({"/loadSocials"})
|
|
|
- public RetResult loadSocials(){
|
|
|
- List<SocialsProvider> socialsProviderList = socialSignOnProviderService.getSocialSignOnProviders();
|
|
|
+ public RetResult loadSocials()
|
|
|
+ {
|
|
|
+ List<SocialsProvider> socialsProviderList = socialSignOnProviderService.getSocialSignOnProviders();
|
|
|
RetResult result = new RetResult();
|
|
|
result.setCode(RetCode.SUCCESS);
|
|
|
result.setMsg("查询成功");
|
|
@@ -175,6 +187,4 @@ public class ThirdLoginController
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
}
|