로그인 자동 분기 처리

This commit is contained in:
KNKIM 2021-11-16 15:13:38 +09:00
parent 0d4ece6dd7
commit 0740c68f4c
5 changed files with 45 additions and 49 deletions

View File

@ -1,7 +1,11 @@
package nlib.security;
import javax.servlet.http.HttpServletRequest;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.MediaType;
import org.springframework.security.access.annotation.Secured;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.AuthenticationProvider;
import org.springframework.security.authentication.dao.DaoAuthenticationProvider;
@ -13,9 +17,13 @@ import org.springframework.security.config.annotation.web.configuration.EnableWe
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import nlib.cmm.crypto.NlibPasswordEncoder;
import nlib.cmm.service.NlibProperty;
import nlib.user.service.NlibLoginVO;
/**
* <pre>
@ -62,50 +70,30 @@ public class SpringSecurityConfig extends WebSecurityConfigurerAdapter {
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()
.antMatchers("/**").permitAll()
.and().csrf()
.disable();
/*
.antMatchers("/login/**").permitAll()
.antMatchers("/member/*.do").permitAll()
.antMatchers("/member/*.ajax").permitAll()
.antMatchers("/member/naver/*.do").permitAll()
.antMatchers("/member/google/*.do").permitAll()
.antMatchers("/member/kakao/*.do").permitAll()
.antMatchers("/userInfo/*.do").permitAll()
.antMatchers("/info/inform/*.do").permitAll()
.antMatchers("/").permitAll()
.antMatchers("/index.jsp").permitAll()
.antMatchers("/index.do").permitAll()
.antMatchers("/main/header.do").permitAll()
.antMatchers("/main/menu.do").permitAll()
.antMatchers("/rent/*.do").permitAll()
.antMatchers("/collection/*.do").permitAll()
.antMatchers("/sample/password/getSampleEncoder.do").permitAll()
.antMatchers("/sample/*.do").permitAll()
.antMatchers("/ * / *Ajax.do").permitAll()
.antMatchers("/fileupload/**").permitAll()
.antMatchers("/board/**").permitAll()
.antMatchers("/inform/**").permitAll()
.antMatchers("/test/**").permitAll()
.antMatchers("/alert/**").permitAll()
.antMatchers("/code/**").permitAll()
.antMatchers("/homes/**").permitAll()
.antMatchers("/homes/**").permitAll()
.antMatchers("/cart/**").permitAll()
.antMatchers("/bbs/**").permitAll()
.antMatchers("/search/**").permitAll()
.antMatchers("/*.html").permitAll()
.anyRequest().authenticated()
.and().formLogin()
.loginPage(NlibProperty.getString("login.url"))
.loginPage(NlibProperty.getString("login.url") + "?login=req")
.permitAll()
.and().csrf()
.disable();
*/
http.logout()
.logoutSuccessUrl("/login/logout.do")
.invalidateHttpSession(true).deleteCookies("JSESSIONID")
;
//--------------------------------------
// 안내
//--------------------------------------
// 로그인이 필요한 컨에 대하여 컨트롤러의 해당 함수에
// @Secured(SecUserVO.ROLE_USER)
// 선언할
//
// (ex)
//
// @Secured("ROLE_USER")
// @RequestMapping(value="/userInfo/getMyHome.do")
// public String getMyHome(HttpServletRequest request, ModelMap model) throws Exception { ... }
//--------------------------------------
}
@Bean

View File

@ -225,6 +225,7 @@ public class LoginController extends NlibCommonController {
HttpServletResponse res,
@RequestParam(required = false) String callType,
@RequestParam(required = false) String returnUrl,
@RequestParam(required = false) String login,
@RequestParam(required = false) String logout,
@RequestParam(required = false) String error,
@RequestParam(required = false) String message,
@ -283,6 +284,8 @@ public class LoginController extends NlibCommonController {
model.addAttribute("message", "로그아웃되었습니다. 감사합니다.");
}
model.addAttribute("login", login); // "req" 경우, 로그인 필수 안내 표출
String retScreen = "nlib/login/loginFormPopup";
if(OAuthLogin.CALL_TYPE_MEMBER.equalsIgnoreCase(callType)) retScreen = "nlib/login/memberSnsForm";
else if(reqPath.equalsIgnoreCase("/login/loginForm.do")) retScreen = "nlib/login/loginForm";

View File

@ -20,6 +20,7 @@ import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.annotation.Secured;
import org.springframework.security.core.Authentication;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
@ -39,6 +40,7 @@ import nlib.col.service.ReadService;
import nlib.col.service.RentService;
import nlib.restful.service.DataApiResVO;
import nlib.security.SecUserDetailsService;
import nlib.security.SecUserVO;
import nlib.user.service.LoginService;
import nlib.user.service.NlibLoginVO;
import nlib.user.service.UserInfoService;
@ -292,13 +294,13 @@ public class UserInfoController extends NlibCommonController {
* @return
* @throws Exception
*/
@Secured("ROLE_USER")
@RequestMapping(value="/userInfo/getMyHome.do")
public String getMyHome(HttpServletRequest request, ModelMap model) throws Exception {
NlibLoginVO loginVO = getNlibLoginVO(request);
log.debug("getMemberQrcode : loginVO=" + loginVO.toString());
// 로그인 계정 정보 추가 DDDDDDDDDDDDDDDDdd
model.addAttribute("loginVO", loginVO);
// 이전접속정보

View File

@ -38,23 +38,21 @@
</script>
<!-- 로그인 섹션 -->
<section class="location join">
<section class="join succ dormant">
<h2 class="blind">로그인 섹션영역</h2>
<div class="inner">
<div class="row-top">
<div class="location-box">
<ul class="loc">
<li>HOME</li>
<li class="on">로그인</li>
</ul>
<ul class="tit">
<li><span>로그인</span></li>
</ul>
</div>
<div class="arr"><img src="/images/icon/icon-join-arr2.png" alt="화살표 아이콘"></div>
<div class="icon"><img src="/images/icon/icon-dormant.png" alt="자물쇠 아이콘"></div>
<c:if test='${empty login }'>
<p>로그인 안내</p>
</c:if>
<c:if test='${login eq "req" }'>
<p>로그인 후, 이용해 주시기 바랍니다.</p>
</c:if>
</div>
<div class="row-bottom">
<div class="join-box">
<div class="login">
<div class="Btn Naver"><button type="button" onclick="location.href='${naverUrl}';">네이버 아이디로 로그인</button></div>
<div class="Btn Kakao"><button type="button" onclick="location.href='${kakaoUrl}';">카카오 로그인</button></div>

View File

@ -36,7 +36,12 @@
<div class="inner">
<div class="row-top">
<div class="icon"><img src="/images/icon/icon-dormant.png" alt="자물쇠 아이콘"></div>
<c:if test='${logout == "" }'>
<p>로그인 및 회원가입 안내</p>
</c:if>
<c:if test='${logout == "logout" }'>
<p>로그인 안내</p>
</c:if>
</div>
<div class="row-bottom">
<div class="join-box">