commit
9d46e6eb2b
@ -1,15 +1,29 @@
|
|||||||
package com.mindskip.xzs.base;
|
package com.mindskip.xzs.base;
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author 武汉思维跳跃科技有限公司
|
* @author 武汉思维跳跃科技有限公司
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Data
|
|
||||||
public class BasePage {
|
public class BasePage {
|
||||||
|
|
||||||
private Integer pageIndex;
|
private Integer pageIndex;
|
||||||
|
|
||||||
private Integer pageSize;
|
private Integer pageSize;
|
||||||
|
|
||||||
|
public Integer getPageIndex() {
|
||||||
|
return pageIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPageIndex(Integer pageIndex) {
|
||||||
|
this.pageIndex = pageIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getPageSize() {
|
||||||
|
return pageSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPageSize(Integer pageSize) {
|
||||||
|
this.pageSize = pageSize;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,25 @@
|
|||||||
package com.mindskip.xzs.configuration.property;
|
package com.mindskip.xzs.configuration.property;
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public class PasswordKeyConfig {
|
public class PasswordKeyConfig {
|
||||||
private String publicKey;
|
private String publicKey;
|
||||||
|
|
||||||
private String privateKey;
|
private String privateKey;
|
||||||
|
|
||||||
|
public String getPublicKey() {
|
||||||
|
return publicKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPublicKey(String publicKey) {
|
||||||
|
this.publicKey = publicKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPrivateKey() {
|
||||||
|
return privateKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPrivateKey(String privateKey) {
|
||||||
|
this.privateKey = privateKey;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,46 @@
|
|||||||
package com.mindskip.xzs.configuration.property;
|
package com.mindskip.xzs.configuration.property;
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Data
|
|
||||||
public class QnConfig {
|
public class QnConfig {
|
||||||
|
|
||||||
private String url;
|
private String url;
|
||||||
private String bucket;
|
private String bucket;
|
||||||
private String accessKey;
|
private String accessKey;
|
||||||
private String secretKey;
|
private String secretKey;
|
||||||
|
|
||||||
|
public String getUrl() {
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUrl(String url) {
|
||||||
|
this.url = url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBucket() {
|
||||||
|
return bucket;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBucket(String bucket) {
|
||||||
|
this.bucket = bucket;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAccessKey() {
|
||||||
|
return accessKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAccessKey(String accessKey) {
|
||||||
|
this.accessKey = accessKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSecretKey() {
|
||||||
|
return secretKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSecretKey(String secretKey) {
|
||||||
|
this.secretKey = secretKey;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.mindskip.xzs.configuration.property;
|
package com.mindskip.xzs.configuration.property;
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -10,10 +9,43 @@ import java.util.List;
|
|||||||
* @author 武汉思维跳跃科技有限公司
|
* @author 武汉思维跳跃科技有限公司
|
||||||
*/
|
*/
|
||||||
@ConfigurationProperties(prefix = "system")
|
@ConfigurationProperties(prefix = "system")
|
||||||
@Data
|
|
||||||
public class SystemConfig {
|
public class SystemConfig {
|
||||||
|
|
||||||
private PasswordKeyConfig pwdKey;
|
private PasswordKeyConfig pwdKey;
|
||||||
private List<String> securityIgnoreUrls;
|
private List<String> securityIgnoreUrls;
|
||||||
private WxConfig wx;
|
private WxConfig wx;
|
||||||
private QnConfig qn;
|
private QnConfig qn;
|
||||||
|
|
||||||
|
public PasswordKeyConfig getPwdKey() {
|
||||||
|
return pwdKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPwdKey(PasswordKeyConfig pwdKey) {
|
||||||
|
this.pwdKey = pwdKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getSecurityIgnoreUrls() {
|
||||||
|
return securityIgnoreUrls;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSecurityIgnoreUrls(List<String> securityIgnoreUrls) {
|
||||||
|
this.securityIgnoreUrls = securityIgnoreUrls;
|
||||||
|
}
|
||||||
|
|
||||||
|
public WxConfig getWx() {
|
||||||
|
return wx;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setWx(WxConfig wx) {
|
||||||
|
this.wx = wx;
|
||||||
|
}
|
||||||
|
|
||||||
|
public QnConfig getQn() {
|
||||||
|
return qn;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setQn(QnConfig qn) {
|
||||||
|
this.qn = qn;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,47 @@
|
|||||||
package com.mindskip.xzs.configuration.property;
|
package com.mindskip.xzs.configuration.property;
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Data
|
|
||||||
public class WxConfig {
|
public class WxConfig {
|
||||||
|
|
||||||
|
|
||||||
private String appid;
|
private String appid;
|
||||||
private String secret;
|
private String secret;
|
||||||
private Duration tokenToLive;
|
private Duration tokenToLive;
|
||||||
private List<String> securityIgnoreUrls;
|
private List<String> securityIgnoreUrls;
|
||||||
|
|
||||||
|
public String getAppid() {
|
||||||
|
return appid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAppid(String appid) {
|
||||||
|
this.appid = appid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSecret() {
|
||||||
|
return secret;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSecret(String secret) {
|
||||||
|
this.secret = secret;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Duration getTokenToLive() {
|
||||||
|
return tokenToLive;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTokenToLive(Duration tokenToLive) {
|
||||||
|
this.tokenToLive = tokenToLive;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getSecurityIgnoreUrls() {
|
||||||
|
return securityIgnoreUrls;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSecurityIgnoreUrls(List<String> securityIgnoreUrls) {
|
||||||
|
this.securityIgnoreUrls = securityIgnoreUrls;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@ package com.mindskip.xzs.configuration.spring.mvc;
|
|||||||
|
|
||||||
import com.mindskip.xzs.configuration.property.SystemConfig;
|
import com.mindskip.xzs.configuration.property.SystemConfig;
|
||||||
import com.mindskip.xzs.configuration.spring.wx.TokenHandlerInterceptor;
|
import com.mindskip.xzs.configuration.spring.wx.TokenHandlerInterceptor;
|
||||||
import lombok.AllArgsConstructor;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.web.servlet.config.annotation.*;
|
import org.springframework.web.servlet.config.annotation.*;
|
||||||
|
|
||||||
@ -14,12 +14,17 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@AllArgsConstructor
|
|
||||||
public class WebMvcConfiguration extends WebMvcConfigurationSupport {
|
public class WebMvcConfiguration extends WebMvcConfigurationSupport {
|
||||||
|
|
||||||
private final TokenHandlerInterceptor tokenHandlerInterceptor;
|
private final TokenHandlerInterceptor tokenHandlerInterceptor;
|
||||||
private final SystemConfig systemConfig;
|
private final SystemConfig systemConfig;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public WebMvcConfiguration(TokenHandlerInterceptor tokenHandlerInterceptor, SystemConfig systemConfig) {
|
||||||
|
this.tokenHandlerInterceptor = tokenHandlerInterceptor;
|
||||||
|
this.systemConfig = systemConfig;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addViewControllers(ViewControllerRegistry registry) {
|
public void addViewControllers(ViewControllerRegistry registry) {
|
||||||
registry.addRedirectViewController("/", "/student/index.html");
|
registry.addRedirectViewController("/", "/student/index.html");
|
||||||
|
@ -1,14 +1,37 @@
|
|||||||
package com.mindskip.xzs.configuration.spring.security;
|
package com.mindskip.xzs.configuration.spring.security;
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author 武汉思维跳跃科技有限公司
|
* @author 武汉思维跳跃科技有限公司
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Data
|
|
||||||
public class AuthenticationBean {
|
public class AuthenticationBean {
|
||||||
private String userName;
|
private String userName;
|
||||||
private String password;
|
private String password;
|
||||||
private boolean remember;
|
private boolean remember;
|
||||||
|
|
||||||
|
public String getUserName() {
|
||||||
|
return userName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUserName(String userName) {
|
||||||
|
this.userName = userName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPassword() {
|
||||||
|
return password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPassword(String password) {
|
||||||
|
this.password = password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isRemember() {
|
||||||
|
return remember;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRemember(boolean remember) {
|
||||||
|
this.remember = remember;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ import com.mindskip.xzs.base.SystemCode;
|
|||||||
import com.mindskip.xzs.domain.UserEventLog;
|
import com.mindskip.xzs.domain.UserEventLog;
|
||||||
import com.mindskip.xzs.event.UserEvent;
|
import com.mindskip.xzs.event.UserEvent;
|
||||||
import com.mindskip.xzs.service.UserService;
|
import com.mindskip.xzs.service.UserService;
|
||||||
import lombok.AllArgsConstructor;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.ApplicationEventPublisher;
|
import org.springframework.context.ApplicationEventPublisher;
|
||||||
import org.springframework.security.core.Authentication;
|
import org.springframework.security.core.Authentication;
|
||||||
import org.springframework.security.core.userdetails.User;
|
import org.springframework.security.core.userdetails.User;
|
||||||
@ -23,12 +23,17 @@ import java.util.Date;
|
|||||||
* @author 武汉思维跳跃科技有限公司
|
* @author 武汉思维跳跃科技有限公司
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
@AllArgsConstructor
|
|
||||||
public class RestAuthenticationSuccessHandler extends SimpleUrlAuthenticationSuccessHandler {
|
public class RestAuthenticationSuccessHandler extends SimpleUrlAuthenticationSuccessHandler {
|
||||||
|
|
||||||
private final ApplicationEventPublisher eventPublisher;
|
private final ApplicationEventPublisher eventPublisher;
|
||||||
private final UserService userService;
|
private final UserService userService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public RestAuthenticationSuccessHandler(ApplicationEventPublisher eventPublisher, UserService userService) {
|
||||||
|
this.eventPublisher = eventPublisher;
|
||||||
|
this.userService = userService;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException {
|
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException {
|
||||||
User springUser = (User) authentication.getPrincipal();
|
User springUser = (User) authentication.getPrincipal();
|
||||||
|
@ -5,7 +5,7 @@ import com.mindskip.xzs.domain.User;
|
|||||||
import com.mindskip.xzs.domain.UserEventLog;
|
import com.mindskip.xzs.domain.UserEventLog;
|
||||||
import com.mindskip.xzs.event.UserEvent;
|
import com.mindskip.xzs.event.UserEvent;
|
||||||
import com.mindskip.xzs.service.UserService;
|
import com.mindskip.xzs.service.UserService;
|
||||||
import lombok.AllArgsConstructor;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.ApplicationEventPublisher;
|
import org.springframework.context.ApplicationEventPublisher;
|
||||||
import org.springframework.security.core.Authentication;
|
import org.springframework.security.core.Authentication;
|
||||||
import org.springframework.security.web.authentication.logout.SimpleUrlLogoutSuccessHandler;
|
import org.springframework.security.web.authentication.logout.SimpleUrlLogoutSuccessHandler;
|
||||||
@ -21,12 +21,17 @@ import java.util.Date;
|
|||||||
* @author 武汉思维跳跃科技有限公司
|
* @author 武汉思维跳跃科技有限公司
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
@AllArgsConstructor
|
|
||||||
public class RestLogoutSuccessHandler extends SimpleUrlLogoutSuccessHandler {
|
public class RestLogoutSuccessHandler extends SimpleUrlLogoutSuccessHandler {
|
||||||
|
|
||||||
private final ApplicationEventPublisher eventPublisher;
|
private final ApplicationEventPublisher eventPublisher;
|
||||||
private final UserService userService;
|
private final UserService userService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public RestLogoutSuccessHandler(ApplicationEventPublisher eventPublisher, UserService userService) {
|
||||||
|
this.eventPublisher = eventPublisher;
|
||||||
|
this.userService = userService;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) {
|
public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) {
|
||||||
org.springframework.security.core.userdetails.User springUser = (org.springframework.security.core.userdetails.User) authentication.getPrincipal();
|
org.springframework.security.core.userdetails.User springUser = (org.springframework.security.core.userdetails.User) authentication.getPrincipal();
|
||||||
|
@ -3,7 +3,7 @@ package com.mindskip.xzs.configuration.spring.security;
|
|||||||
import com.mindskip.xzs.configuration.property.CookieConfig;
|
import com.mindskip.xzs.configuration.property.CookieConfig;
|
||||||
import com.mindskip.xzs.configuration.property.SystemConfig;
|
import com.mindskip.xzs.configuration.property.SystemConfig;
|
||||||
import com.mindskip.xzs.domain.enums.RoleEnum;
|
import com.mindskip.xzs.domain.enums.RoleEnum;
|
||||||
import lombok.AllArgsConstructor;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||||
@ -27,7 +27,6 @@ import java.util.List;
|
|||||||
public class SecurityConfigurer {
|
public class SecurityConfigurer {
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@AllArgsConstructor
|
|
||||||
public static class FormLoginWebSecurityConfigurerAdapter extends WebSecurityConfigurerAdapter {
|
public static class FormLoginWebSecurityConfigurerAdapter extends WebSecurityConfigurerAdapter {
|
||||||
|
|
||||||
private final SystemConfig systemConfig;
|
private final SystemConfig systemConfig;
|
||||||
@ -39,6 +38,18 @@ public class SecurityConfigurer {
|
|||||||
private final RestLogoutSuccessHandler restLogoutSuccessHandler;
|
private final RestLogoutSuccessHandler restLogoutSuccessHandler;
|
||||||
private final RestAccessDeniedHandler restAccessDeniedHandler;
|
private final RestAccessDeniedHandler restAccessDeniedHandler;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public FormLoginWebSecurityConfigurerAdapter(SystemConfig systemConfig, LoginAuthenticationEntryPoint restAuthenticationEntryPoint, RestAuthenticationProvider restAuthenticationProvider, RestDetailsServiceImpl formDetailsService, RestAuthenticationSuccessHandler restAuthenticationSuccessHandler, RestAuthenticationFailureHandler restAuthenticationFailureHandler, RestLogoutSuccessHandler restLogoutSuccessHandler, RestAccessDeniedHandler restAccessDeniedHandler) {
|
||||||
|
this.systemConfig = systemConfig;
|
||||||
|
this.restAuthenticationEntryPoint = restAuthenticationEntryPoint;
|
||||||
|
this.restAuthenticationProvider = restAuthenticationProvider;
|
||||||
|
this.formDetailsService = formDetailsService;
|
||||||
|
this.restAuthenticationSuccessHandler = restAuthenticationSuccessHandler;
|
||||||
|
this.restAuthenticationFailureHandler = restAuthenticationFailureHandler;
|
||||||
|
this.restLogoutSuccessHandler = restLogoutSuccessHandler;
|
||||||
|
this.restAccessDeniedHandler = restAccessDeniedHandler;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param http http
|
* @param http http
|
||||||
* @throws Exception exception
|
* @throws Exception exception
|
||||||
|
Loading…
Reference in New Issue
Block a user