学生资助、学生奖惩、学籍异动内容修改
This commit is contained in:
@@ -20,6 +20,8 @@ import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
|
||||
import org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer;
|
||||
import org.springframework.security.config.http.SessionCreationPolicy;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.security.core.userdetails.UserDetailsService;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
|
||||
@@ -38,6 +40,7 @@ import com.srs.framework.security.handle.LogoutSuccessHandlerImpl;
|
||||
*/
|
||||
@EnableGlobalMethodSecurity(prePostEnabled = true, securedEnabled = true)
|
||||
public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
private static final Logger log = LoggerFactory.getLogger(SecurityConfig.class);
|
||||
|
||||
@Autowired
|
||||
private CasProperties casProperties;
|
||||
@@ -232,7 +235,9 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
@Bean
|
||||
public ServiceProperties serviceProperties() {
|
||||
ServiceProperties serviceProperties = new ServiceProperties();
|
||||
serviceProperties.setService(casProperties.getAppServerUrl() + casProperties.getAppLoginUrl());
|
||||
String service = casProperties.getAppServerUrl() + casProperties.getAppLoginUrl();
|
||||
serviceProperties.setService(service);
|
||||
log.info("cas_service=" + service);
|
||||
serviceProperties.setAuthenticateAllArtifacts(true);
|
||||
return serviceProperties;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ import java.io.PrintWriter;
|
||||
@Service
|
||||
public class CasAuthenticationSuccessHandler extends SavedRequestAwareAuthenticationSuccessHandler {
|
||||
|
||||
protected final Log logger = LogFactory.getLog(this.getClass());
|
||||
protected final Log logger = LogFactory.getLog(this.getClass());
|
||||
|
||||
private RequestCache requestCache = new HttpSessionRequestCache();
|
||||
|
||||
@@ -71,7 +71,7 @@ public class CasAuthenticationSuccessHandler extends SavedRequestAwareAuthentica
|
||||
// httpSession.setAttribute(Constants.CAS_TOKEN, token);
|
||||
// //登录成功后跳转到前端登录页面
|
||||
// if(com.srs.common.utils.StringUtils.isNotNull(qqtype)){
|
||||
// String webindex="http://zhxg.gxsdxy.cn/hh/#/pages/index/index";
|
||||
// String webindex="https://zhxg.gxsdxy.cn/hh/#/pages/index/index";
|
||||
// getRedirectStrategy().sendRedirect(request, response, casProperties.getWebUrl()+"?jwt="+token);
|
||||
// }else{
|
||||
// getRedirectStrategy().sendRedirect(request, response, casProperties.getWebUrl()+"?jwt="+token);
|
||||
@@ -105,7 +105,8 @@ public class CasAuthenticationSuccessHandler extends SavedRequestAwareAuthentica
|
||||
// httpSession.setAttribute(Constants.CAS_TOKEN, token);
|
||||
// // 登录成功后跳转到前端登录页面
|
||||
// if (isMobileDevice(request)) {
|
||||
//// String webindex = "http://zhxg.gxsdxy.cn/wab/#/pages/index/index";
|
||||
|
||||
/// / String webindex = "https://zhxg.gxsdxy.cn/wab/#/pages/index/index";
|
||||
// String waburl = casProperties.getWabUrl()+"?jwt="+ token;
|
||||
// getRedirectStrategy().sendRedirect(request, response, waburl);
|
||||
// } else {
|
||||
@@ -113,51 +114,54 @@ public class CasAuthenticationSuccessHandler extends SavedRequestAwareAuthentica
|
||||
// getRedirectStrategy().sendRedirect(request, response, weburl);
|
||||
// }
|
||||
// }
|
||||
|
||||
@Override
|
||||
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response,
|
||||
Authentication authentication) throws ServletException, IOException {
|
||||
String targetUrlParameter = getTargetUrlParameter();
|
||||
if (isAlwaysUseDefaultTargetUrl()
|
||||
|| (targetUrlParameter != null && StringUtils.hasText(request.getParameter(targetUrlParameter)))) {
|
||||
requestCache.removeRequest(request, response);
|
||||
super.onAuthenticationSuccess(request, response, authentication);
|
||||
return;
|
||||
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response,
|
||||
Authentication authentication) throws ServletException, IOException {
|
||||
String targetUrlParameter = getTargetUrlParameter();
|
||||
if (isAlwaysUseDefaultTargetUrl()
|
||||
|| (targetUrlParameter != null && StringUtils.hasText(request.getParameter(targetUrlParameter)))) {
|
||||
requestCache.removeRequest(request, response);
|
||||
super.onAuthenticationSuccess(request, response, authentication);
|
||||
return;
|
||||
}
|
||||
clearAuthenticationAttributes(request);
|
||||
LoginUser userDetails = (LoginUser) authentication.getPrincipal();
|
||||
String token = tokenService.createToken(userDetails);
|
||||
|
||||
// 设置后端认证成功标识
|
||||
HttpSession httpSession = request.getSession();
|
||||
httpSession.setAttribute(Constants.CAS_TOKEN, token);
|
||||
|
||||
// 构造跳转 URL
|
||||
String ua = request.getHeader("User-Agent");
|
||||
String referer = request.getHeader("Referer");
|
||||
String requestUrl = request.getRequestURL().toString();
|
||||
String redirectUrl;
|
||||
if (isMobileDevice(request)) {
|
||||
redirectUrl = casProperties.getWabUrl() + "?jwt=" + token;
|
||||
} else {
|
||||
redirectUrl = casProperties.getWebUrl() + "?jwt=" + token;
|
||||
}
|
||||
logger.info("cas_login_success ua=" + ua + " referer=" + referer + " requestUrl=" + requestUrl + " redirectUrl=" + redirectUrl);
|
||||
|
||||
// 使用客户端 JS 跳转替代 sendRedirect
|
||||
response.setContentType("text/html;charset=UTF-8");
|
||||
PrintWriter writer = response.getWriter();
|
||||
writer.write("<!DOCTYPE html>\n" +
|
||||
"<html>\n" +
|
||||
"<head>\n" +
|
||||
" <meta charset=\"UTF-8\">\n" +
|
||||
" <title>Redirecting...</title>\n" +
|
||||
" <script type=\"text/javascript\">\n" +
|
||||
" window.location.href = '" + redirectUrl + "';\n" +
|
||||
" </script>\n" +
|
||||
"</head>\n" +
|
||||
"<body>\n" +
|
||||
" <p>正在跳转,请稍候...</p>\n" +
|
||||
"</body>\n" +
|
||||
"</html>");
|
||||
writer.flush();
|
||||
}
|
||||
clearAuthenticationAttributes(request);
|
||||
LoginUser userDetails = (LoginUser) authentication.getPrincipal();
|
||||
String token = tokenService.createToken(userDetails);
|
||||
|
||||
// 设置后端认证成功标识
|
||||
HttpSession httpSession = request.getSession();
|
||||
httpSession.setAttribute(Constants.CAS_TOKEN, token);
|
||||
|
||||
// 构造跳转 URL
|
||||
String redirectUrl;
|
||||
if (isMobileDevice(request)) {
|
||||
redirectUrl = casProperties.getWabUrl() + "?jwt=" + token;
|
||||
} else {
|
||||
redirectUrl = casProperties.getWebUrl() + "?jwt=" + token;
|
||||
}
|
||||
|
||||
// 使用客户端 JS 跳转替代 sendRedirect
|
||||
response.setContentType("text/html;charset=UTF-8");
|
||||
PrintWriter writer = response.getWriter();
|
||||
writer.write("<!DOCTYPE html>\n" +
|
||||
"<html>\n" +
|
||||
"<head>\n" +
|
||||
" <meta charset=\"UTF-8\">\n" +
|
||||
" <title>Redirecting...</title>\n" +
|
||||
" <script type=\"text/javascript\">\n" +
|
||||
" window.location.href = '" + redirectUrl + "';\n" +
|
||||
" </script>\n" +
|
||||
"</head>\n" +
|
||||
"<body>\n" +
|
||||
" <p>正在跳转,请稍候...</p>\n" +
|
||||
"</body>\n" +
|
||||
"</html>");
|
||||
writer.flush();
|
||||
}
|
||||
|
||||
|
||||
private boolean isMobileDevice(HttpServletRequest request) {
|
||||
@@ -165,7 +169,7 @@ public void onAuthenticationSuccess(HttpServletRequest request, HttpServletRespo
|
||||
if (userAgent == null) {
|
||||
return false;
|
||||
}
|
||||
return userAgent.matches("(?i).*\\b(mobi|android|iphone|ipad|ipod)\\b.*");
|
||||
return userAgent.matches("(?i).*\\b(mobi|android|iphone|ipad|ipod|wxwork)\\b.*");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user