Commit 8aeefde2 by fengshuonan

整合第三方登录到系统管理

parent 00e6f2a5
......@@ -21,7 +21,6 @@
| guns-base | guns的基础模块 |
| guns-base-email | 邮件发送模块 |
| guns-base-sms | 短信发送模块(对接阿里云短信) |
| guns-base-third-login | 第三方登录 |
| guns-base-timers | 分布式任务调度执行器 |
| guns-sys | guns系统管理的基础业务模块 |
| guns-vip-gen | guns代码生成器模块 |
......
### Guns第三方登录,接入qq和码云登录
### 配置在cn.stylefeng.guns.oauth.modular.factory.OAuthRequestFactory里边
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>cn.stylefeng</groupId>
<artifactId>guns-vip</artifactId>
<version>1.0.0</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>guns-base-third-login</artifactId>
<packaging>jar</packaging>
<dependencies>
<!--基础组件-->
<dependency>
<groupId>cn.stylefeng</groupId>
<artifactId>guns-sys</artifactId>
<version>1.0.0</version>
</dependency>
<!--第三方登录-->
<dependency>
<groupId>me.zhyd.oauth</groupId>
<artifactId>JustAuth</artifactId>
<version>1.6.0-beta</version>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
</build>
</project>
package cn.stylefeng.guns.oauth.config;
import org.springframework.context.annotation.Configuration;
/**
* 第三方登录配置
*
* @author fengshuonan
* @Date 2019/6/9 16:46
*/
@Configuration
public class OAuthLoginConfig {
}
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
cn.stylefeng.guns.oauth.config.OAuthLoginConfig
\ No newline at end of file
......@@ -24,6 +24,13 @@
<version>1.0.0</version>
</dependency>
<!-- 第三方登录-->
<dependency>
<groupId>me.zhyd.oauth</groupId>
<artifactId>JustAuth</artifactId>
<version>1.6.0-beta</version>
</dependency>
</dependencies>
<build>
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.stylefeng.guns.oauth.core.exception;
package cn.stylefeng.guns.sys.core.exception.oauth;
import cn.stylefeng.roses.kernel.model.exception.AbstractBaseExceptionEnum;
......
package cn.stylefeng.guns.oauth.core.exception;
package cn.stylefeng.guns.sys.core.exception.oauth;
import cn.stylefeng.roses.kernel.model.exception.AbstractBaseExceptionEnum;
import cn.stylefeng.roses.kernel.model.exception.ServiceException;
......
package cn.stylefeng.guns.oauth.core.shiro;
package cn.stylefeng.guns.sys.core.shiro.oauth;
import lombok.Data;
import org.apache.shiro.authc.UsernamePasswordToken;
......
package cn.stylefeng.guns.oauth.core.shiro.matcher;
package cn.stylefeng.guns.sys.core.shiro.oauth.matcher;
import cn.stylefeng.guns.oauth.core.shiro.LoginType;
import cn.stylefeng.guns.oauth.core.shiro.OAuthToken;
import cn.stylefeng.guns.sys.core.shiro.oauth.LoginType;
import cn.stylefeng.guns.sys.core.shiro.oauth.OAuthToken;
import org.apache.shiro.authc.AuthenticationInfo;
import org.apache.shiro.authc.AuthenticationToken;
import org.apache.shiro.authc.credential.HashedCredentialsMatcher;
......
package cn.stylefeng.guns.oauth.modular.controller;
package cn.stylefeng.guns.sys.modular.third.controller;
import cn.stylefeng.guns.oauth.modular.service.LoginService;
import cn.stylefeng.guns.oauth.modular.service.OauthUserInfoService;
import cn.stylefeng.guns.sys.core.shiro.ShiroKit;
import cn.stylefeng.guns.sys.modular.third.factory.OAuthRequestFactory;
import cn.stylefeng.guns.sys.modular.third.service.LoginService;
import cn.stylefeng.guns.sys.modular.third.service.OauthUserInfoService;
import cn.stylefeng.roses.core.base.controller.BaseController;
import lombok.extern.slf4j.Slf4j;
import me.zhyd.oauth.model.AuthResponse;
......@@ -18,8 +19,6 @@ import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import static cn.stylefeng.guns.oauth.modular.factory.OAuthRequestFactory.getAuthRequest;
/**
* OAuth统一回调地址
*
......@@ -45,7 +44,7 @@ public class OAuthController extends BaseController {
*/
@RequestMapping("/render/{source}")
public void renderAuth(@PathVariable("source") String source, HttpServletResponse response) throws IOException {
AuthRequest authRequest = getAuthRequest(source);
AuthRequest authRequest = OAuthRequestFactory.getAuthRequest(source);
response.sendRedirect(authRequest.authorize());
}
......@@ -59,7 +58,7 @@ public class OAuthController extends BaseController {
public String callback(@PathVariable("source") String source, @RequestParam("code") String code, RedirectAttributes model) {
//通过回调的code,请求对应的oauth server获取用户基本信息和token
AuthRequest authRequest = getAuthRequest(source);
AuthRequest authRequest = OAuthRequestFactory.getAuthRequest(source);
AuthResponse authResponse = authRequest.login(code);
AuthUser oauthUser = (AuthUser) authResponse.getData();
......
package cn.stylefeng.guns.oauth.modular.entity;
package cn.stylefeng.guns.sys.modular.third.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
......
package cn.stylefeng.guns.oauth.modular.factory;
package cn.stylefeng.guns.sys.modular.third.factory;
import me.zhyd.oauth.config.AuthConfig;
import me.zhyd.oauth.exception.AuthException;
......
package cn.stylefeng.guns.oauth.modular.factory;
package cn.stylefeng.guns.sys.modular.third.factory;
import cn.stylefeng.guns.oauth.modular.entity.OauthUserInfo;
import cn.stylefeng.guns.sys.modular.third.entity.OauthUserInfo;
import cn.stylefeng.guns.sys.core.constant.Const;
import cn.stylefeng.guns.sys.core.constant.state.ManagerStatus;
import cn.stylefeng.guns.sys.core.shiro.ShiroKit;
......
package cn.stylefeng.guns.oauth.modular.mapper;
package cn.stylefeng.guns.sys.modular.third.mapper;
import cn.stylefeng.guns.oauth.modular.entity.OauthUserInfo;
import cn.stylefeng.guns.oauth.modular.model.params.OauthUserInfoParam;
import cn.stylefeng.guns.oauth.modular.model.result.OauthUserInfoResult;
import cn.stylefeng.guns.sys.modular.third.entity.OauthUserInfo;
import cn.stylefeng.guns.sys.modular.third.model.params.OauthUserInfoParam;
import cn.stylefeng.guns.sys.modular.third.model.result.OauthUserInfoResult;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.stylefeng.guns.oauth.modular.mapper.OauthUserInfoMapper">
<mapper namespace="cn.stylefeng.guns.sys.modular.third.mapper.OauthUserInfoMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="cn.stylefeng.guns.oauth.modular.entity.OauthUserInfo">
<resultMap id="BaseResultMap" type="cn.stylefeng.guns.sys.modular.third.entity.OauthUserInfo">
<id column="oauth_id" property="oauthId" />
<result column="user_id" property="userId" />
<result column="nick_name" property="nickName" />
......@@ -29,25 +29,25 @@
</sql>
<select id="customList" resultType="cn.stylefeng.guns.oauth.modular.model.result.OauthUserInfoResult" parameterType="cn.stylefeng.guns.oauth.modular.model.params.OauthUserInfoParam">
<select id="customList" resultType="cn.stylefeng.guns.sys.modular.third.model.result.OauthUserInfoResult" parameterType="cn.stylefeng.guns.sys.modular.third.model.params.OauthUserInfoParam">
select
<include refid="Base_Column_List"/>
from oauth_user_info where 1 = 1
</select>
<select id="customMapList" resultType="map" parameterType="cn.stylefeng.guns.oauth.modular.model.params.OauthUserInfoParam">
<select id="customMapList" resultType="map" parameterType="cn.stylefeng.guns.sys.modular.third.model.params.OauthUserInfoParam">
select
<include refid="Base_Column_List"/>
from oauth_user_info where 1 = 1
</select>
<select id="customPageList" resultType="cn.stylefeng.guns.oauth.modular.model.result.OauthUserInfoResult" parameterType="cn.stylefeng.guns.oauth.modular.model.params.OauthUserInfoParam">
<select id="customPageList" resultType="cn.stylefeng.guns.sys.modular.third.model.result.OauthUserInfoResult" parameterType="cn.stylefeng.guns.sys.modular.third.model.params.OauthUserInfoParam">
select
<include refid="Base_Column_List"/>
from oauth_user_info where 1 = 1
</select>
<select id="customPageMapList" resultType="map" parameterType="cn.stylefeng.guns.oauth.modular.model.params.OauthUserInfoParam">
<select id="customPageMapList" resultType="map" parameterType="cn.stylefeng.guns.sys.modular.third.model.params.OauthUserInfoParam">
select
<include refid="Base_Column_List"/>
from oauth_user_info where 1 = 1
......
package cn.stylefeng.guns.oauth.modular.model.params;
package cn.stylefeng.guns.sys.modular.third.model.params;
import lombok.Data;
import cn.stylefeng.roses.kernel.model.validator.BaseValidatingParam;
......
package cn.stylefeng.guns.oauth.modular.model.result;
package cn.stylefeng.guns.sys.modular.third.model.result;
import lombok.Data;
import java.util.Date;
......
package cn.stylefeng.guns.oauth.modular.service;
package cn.stylefeng.guns.sys.modular.third.service;
import me.zhyd.oauth.model.AuthUser;
......
package cn.stylefeng.guns.oauth.modular.service;
package cn.stylefeng.guns.sys.modular.third.service;
import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo;
import cn.stylefeng.guns.oauth.modular.entity.OauthUserInfo;
import cn.stylefeng.guns.oauth.modular.model.params.OauthUserInfoParam;
import cn.stylefeng.guns.oauth.modular.model.result.OauthUserInfoResult;
import cn.stylefeng.guns.sys.modular.third.entity.OauthUserInfo;
import cn.stylefeng.guns.sys.modular.third.model.params.OauthUserInfoParam;
import cn.stylefeng.guns.sys.modular.third.model.result.OauthUserInfoResult;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
......
package cn.stylefeng.guns.oauth.modular.service.impl;
package cn.stylefeng.guns.sys.modular.third.service.impl;
import cn.stylefeng.guns.base.shiro.ShiroUser;
import cn.stylefeng.guns.oauth.core.exception.OAuthExceptionEnum;
import cn.stylefeng.guns.oauth.core.exception.OAuthLoginException;
import cn.stylefeng.guns.oauth.core.shiro.OAuthToken;
import cn.stylefeng.guns.oauth.modular.entity.OauthUserInfo;
import cn.stylefeng.guns.oauth.modular.factory.OAuthUserInfoFactory;
import cn.stylefeng.guns.oauth.modular.service.LoginService;
import cn.stylefeng.guns.oauth.modular.service.OauthUserInfoService;
import cn.stylefeng.guns.sys.core.exception.oauth.OAuthExceptionEnum;
import cn.stylefeng.guns.sys.core.exception.oauth.OAuthLoginException;
import cn.stylefeng.guns.sys.core.shiro.ShiroKit;
import cn.stylefeng.guns.sys.core.shiro.oauth.OAuthToken;
import cn.stylefeng.guns.sys.modular.system.entity.User;
import cn.stylefeng.guns.sys.modular.system.service.UserService;
import cn.stylefeng.guns.sys.modular.third.entity.OauthUserInfo;
import cn.stylefeng.guns.sys.modular.third.factory.OAuthUserInfoFactory;
import cn.stylefeng.guns.sys.modular.third.service.LoginService;
import cn.stylefeng.guns.sys.modular.third.service.OauthUserInfoService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import me.zhyd.oauth.model.AuthUser;
import org.springframework.beans.factory.annotation.Autowired;
......
package cn.stylefeng.guns.oauth.modular.service.impl;
package cn.stylefeng.guns.sys.modular.third.service.impl;
import cn.stylefeng.guns.base.pojo.page.LayuiPageFactory;
import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo;
import cn.stylefeng.guns.oauth.modular.entity.OauthUserInfo;
import cn.stylefeng.guns.oauth.modular.mapper.OauthUserInfoMapper;
import cn.stylefeng.guns.oauth.modular.model.params.OauthUserInfoParam;
import cn.stylefeng.guns.oauth.modular.model.result.OauthUserInfoResult;
import cn.stylefeng.guns.oauth.modular.service.OauthUserInfoService;
import cn.stylefeng.guns.sys.modular.third.entity.OauthUserInfo;
import cn.stylefeng.guns.sys.modular.third.mapper.OauthUserInfoMapper;
import cn.stylefeng.guns.sys.modular.third.model.params.OauthUserInfoParam;
import cn.stylefeng.guns.sys.modular.third.model.result.OauthUserInfoResult;
import cn.stylefeng.guns.sys.modular.third.service.OauthUserInfoService;
import cn.stylefeng.roses.core.util.ToolUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
......
......@@ -31,13 +31,6 @@
<version>1.0.0</version>
</dependency>
<!-- 第三方登录 -->
<dependency>
<groupId>cn.stylefeng</groupId>
<artifactId>guns-base-third-login</artifactId>
<version>1.0.0</version>
</dependency>
<!-- 数据源容器-->
<dependency>
<groupId>cn.stylefeng</groupId>
......
......@@ -15,7 +15,7 @@
*/
package cn.stylefeng.guns.config.web;
import cn.stylefeng.guns.oauth.core.shiro.matcher.WithOAuthTokenMatcher;
import cn.stylefeng.guns.sys.core.shiro.oauth.matcher.WithOAuthTokenMatcher;
import cn.stylefeng.guns.sys.core.constant.Const;
import cn.stylefeng.guns.sys.core.properties.GunsProperties;
import cn.stylefeng.guns.sys.core.shiro.GunsUserFilter;
......
......@@ -25,7 +25,6 @@
<module>guns-base-sms</module>
<module>guns-base-email</module>
<module>guns-base-timers</module>
<module>guns-base-third-login</module>
<module>guns-sys</module>
<module>guns-vip-gen</module>
<module>guns-vip-main</module>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment