sns 로그인 수정

This commit is contained in:
JSYOO 2021-11-09 16:52:11 +09:00
parent c34acf02e5
commit 28401512f2
7 changed files with 30 additions and 23 deletions

View File

@ -77,8 +77,8 @@ public class OAuthLogin {
this.oauthVO = oauthVO; this.oauthVO = oauthVO;
} }
public String getOAuthURL() { public String getOAuthURL(String state) {
return this.oauthService.getAuthorizationUrl(); return this.oauthService.getAuthorizationUrl(state);
} }
public OAuthUniversalUser getUserProfile(String code) throws Exception { public OAuthUniversalUser getUserProfile(String code) throws Exception {

View File

@ -12,6 +12,7 @@ public class OAuthVO implements OAuthConfig {
private String clientId; private String clientId;
private String clientSecret; private String clientSecret;
private String redirectUrl; private String redirectUrl;
private String state;
private DefaultApi20 api20Instance; private DefaultApi20 api20Instance;
private String profileUrl; private String profileUrl;
@ -24,7 +25,7 @@ public class OAuthVO implements OAuthConfig {
this.clientId = clientId; this.clientId = clientId;
this.clientSecret = clientSecret; this.clientSecret = clientSecret;
this.redirectUrl = redirectUrl; this.redirectUrl = redirectUrl;
this.state = state;
this.isGoogle = StringUtil.equalsIgnoreCase(GOOGLE_SERVICE_NAME, serviceName); this.isGoogle = StringUtil.equalsIgnoreCase(GOOGLE_SERVICE_NAME, serviceName);
this.isNaver = StringUtil.equalsIgnoreCase(NAVER_SERVICE_NAME, serviceName); this.isNaver = StringUtil.equalsIgnoreCase(NAVER_SERVICE_NAME, serviceName);
this.isKakao = StringUtil.equalsIgnoreCase(KAKAO_SERVICE_NAME, serviceName); this.isKakao = StringUtil.equalsIgnoreCase(KAKAO_SERVICE_NAME, serviceName);
@ -118,4 +119,12 @@ public class OAuthVO implements OAuthConfig {
this.isKakao = isKakao; this.isKakao = isKakao;
} }
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
} }

View File

@ -264,17 +264,18 @@ public class LoginController extends NlibCommonController {
//---------------------------------------------- //----------------------------------------------
// SNS 연동 URL 생성 // SNS 연동 URL 생성
//---------------------------------------------- //----------------------------------------------
String encCouncilJsessionId = AriaCrypto.encode(councilJsessionId);
OAuthLogin naverLogin = new OAuthLogin(naverAuthVO, callType, councilJsessionId); OAuthLogin naverLogin = new OAuthLogin(naverAuthVO, callType, councilJsessionId);
log.debug("naverLogin.getOAuthURL() = "+naverLogin.getOAuthURL()); log.debug("naverLogin.getOAuthURL() = "+naverLogin.getOAuthURL(encCouncilJsessionId));
model.addAttribute("naverUrl", naverLogin.getOAuthURL()); model.addAttribute("naverUrl", naverLogin.getOAuthURL(encCouncilJsessionId));
OAuthLogin googleLogin = new OAuthLogin(googleAuthVO, callType, councilJsessionId); OAuthLogin googleLogin = new OAuthLogin(googleAuthVO, callType, councilJsessionId);
log.debug("googleLogin.getOAuthURL() = "+googleLogin.getOAuthURL()); log.debug("googleLogin.getOAuthURL() = "+googleLogin.getOAuthURL(encCouncilJsessionId));
model.addAttribute("googleUrl", googleLogin.getOAuthURL()); model.addAttribute("googleUrl", googleLogin.getOAuthURL(encCouncilJsessionId));
OAuthLogin kakaoLogin = new OAuthLogin(kakaoAuthVO, OAuthLogin.CALL_TYPE_LOGIN, councilJsessionId); OAuthLogin kakaoLogin = new OAuthLogin(kakaoAuthVO, OAuthLogin.CALL_TYPE_LOGIN, councilJsessionId);
log.debug("kakaoLogin.getOAuthURL() = "+kakaoLogin.getOAuthURL()); log.debug("kakaoLogin.getOAuthURL() = "+kakaoLogin.getOAuthURL(encCouncilJsessionId));
model.addAttribute("kakaoUrl", kakaoLogin.getOAuthURL()); model.addAttribute("kakaoUrl", kakaoLogin.getOAuthURL(encCouncilJsessionId));
model.addAttribute("error", error); model.addAttribute("error", error);
model.addAttribute("message", message); model.addAttribute("message", message);
@ -316,14 +317,12 @@ public class LoginController extends NlibCommonController {
HttpServletRequest req, HttpServletRequest req,
@PathVariable String callType, @PathVariable String callType,
@PathVariable String oauthServiceName, @PathVariable String oauthServiceName,
@RequestParam(required = false) String councilJsessionId,
@RequestParam(required = false) String code, @RequestParam(required = false) String code,
@RequestParam(name = "state" , required = false) String councilJsessionId,
@RequestParam(required = false) String error, @RequestParam(required = false) String error,
Model model, Model model,
HttpSession session) throws Exception { HttpSession session) throws Exception {
String redirectUrl = NlibProperty.getString("home.uri"); // "/index.do"; String redirectUrl = NlibProperty.getString("home.uri"); // "/index.do";
if(StringUtil.isEmpty(councilJsessionId)) { if(StringUtil.isEmpty(councilJsessionId)) {
model.addAttribute("message", "잘못된 접근입니다. (접속문화원 세션정보 오류)"); model.addAttribute("message", "잘못된 접근입니다. (접속문화원 세션정보 오류)");
model.addAttribute("loginBtnYn", "Y"); model.addAttribute("loginBtnYn", "Y");
@ -331,7 +330,6 @@ public class LoginController extends NlibCommonController {
return "nlib/login/loginMessage"; return "nlib/login/loginMessage";
} }
councilJsessionId = AriaCrypto.decode(councilJsessionId); councilJsessionId = AriaCrypto.decode(councilJsessionId);
OAuthUniversalUser tmpUser = SessionConfig.getLoginInfo(councilJsessionId); OAuthUniversalUser tmpUser = SessionConfig.getLoginInfo(councilJsessionId);
if(tmpUser == null || StringUtil.isEmpty(tmpUser.getCouncilHomeUrl())) { if(tmpUser == null || StringUtil.isEmpty(tmpUser.getCouncilHomeUrl())) {
model.addAttribute("message", "잘못된 접근입니다. (접속문화원 정보 오류)"); model.addAttribute("message", "잘못된 접근입니다. (접속문화원 정보 오류)");

View File

@ -8,7 +8,7 @@
<constructor-arg value="naver" /><!-- Service Name --> <constructor-arg value="naver" /><!-- Service Name -->
<constructor-arg value="EUu_FlgfyBlpQwGkXbit" /><!-- naverClientID --> <constructor-arg value="EUu_FlgfyBlpQwGkXbit" /><!-- naverClientID -->
<constructor-arg value="f34KD054kW" /><!-- naverClientSecret --> <constructor-arg value="f34KD054kW" /><!-- naverClientSecret -->
<constructor-arg value="https://nlib-dev.nculture.org/{callType}/{oauthServiceName}/callback.do?councilJsessionId={councilJsessionId}" /><!-- naverRedirectUrl : callType(login|member) --> <constructor-arg value="https://nlib-dev.nculture.org/{callType}/{oauthServiceName}/callback.do" /><!-- naverRedirectUrl : callType(login|member) -->
</bean> </bean>
<!-- GOOGLE OAuth Configuration --> <!-- GOOGLE OAuth Configuration -->
@ -16,7 +16,7 @@
<constructor-arg value="google" /><!-- Service Name --> <constructor-arg value="google" /><!-- Service Name -->
<constructor-arg value="590802608410-a03ul9al205h3h8rvhrlr2tulleftt0o.apps.googleusercontent.com" /><!-- googleClientID --> <constructor-arg value="590802608410-a03ul9al205h3h8rvhrlr2tulleftt0o.apps.googleusercontent.com" /><!-- googleClientID -->
<constructor-arg value="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" /><!-- googleClientSecret --> <constructor-arg value="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" /><!-- googleClientSecret -->
<constructor-arg value="https://nlib-dev.nculture.org/{callType}/{oauthServiceName}/callback.do?councilJsessionId={councilJsessionId}" /><!-- googleRedirectUrl : callType(login|member) --> <constructor-arg value="https://nlib-dev.nculture.org/{callType}/{oauthServiceName}/callback.do" /><!-- googleRedirectUrl : callType(login|member) -->
</bean> </bean>
<!-- KAKAO OAuth Configuration --> <!-- KAKAO OAuth Configuration -->
@ -24,7 +24,7 @@
<constructor-arg value="kakao" /><!-- Service Name --> <constructor-arg value="kakao" /><!-- Service Name -->
<constructor-arg value="9c1b2249240c011edf40a1d487702232" /><!-- kakaoClientID --> <constructor-arg value="9c1b2249240c011edf40a1d487702232" /><!-- kakaoClientID -->
<constructor-arg value="fxv4i1aztudvPj84DEUvMTnzWe29611G" /><!-- kakaoClientSecret --> <constructor-arg value="fxv4i1aztudvPj84DEUvMTnzWe29611G" /><!-- kakaoClientSecret -->
<constructor-arg value="https://nlib-dev.nculture.org/{callType}/{oauthServiceName}/callback.do?councilJsessionId={councilJsessionId}" /><!-- kakaoRedirectUrl : callType(login|member) --> <constructor-arg value="https://nlib-dev.nculture.org/{callType}/{oauthServiceName}/callback.do" /><!-- kakaoRedirectUrl : callType(login|member) -->
</bean> </bean>
</beans> </beans>

View File

@ -57,8 +57,8 @@
<div class="join-box"> <div class="join-box">
<div class="login"> <div class="login">
<div class="Btn Naver"><button type="button" onclick="location.href='${naverUrl}';">네이버 아이디로 로그인</button></div> <div class="Btn Naver"><button type="button" onclick="location.href='${naverUrl}';">네이버 아이디로 로그인</button></div>
<div class="Btn Kakao"><button type="button" onclick="location.href='${googleUrl}';">카카오 로그인</button></div> <div class="Btn Kakao"><button type="button" onclick="location.href='${kakaoUrl}';">카카오 로그인</button></div>
<div class="Btn Google"><button type="button" onclick="location.href='${kakaoUrl}';">Google 계정으로 로그인</button></div> <div class="Btn Google"><button type="button" onclick="location.href='${googleUrl}';">Google 계정으로 로그인</button></div>
</div> </div>
<div class="row Text"> <div class="row Text">
<p>로그인할 때 이용할 SNS를 선택하세요!</p> <p>로그인할 때 이용할 SNS를 선택하세요!</p>

View File

@ -46,8 +46,8 @@
<div class="inner"> <div class="inner">
<div class="row First"> <div class="row First">
<div class="Btn Naver"><button type="button" onclick="location.href='${naverUrl}';">네이버 아이디로 로그인</button></div> <div class="Btn Naver"><button type="button" onclick="location.href='${naverUrl}';">네이버 아이디로 로그인</button></div>
<div class="Btn Kakao"><button type="button" onclick="location.href='${googleUrl}';">카카오 로그인</button></div> <div class="Btn Kakao"><button type="button" onclick="location.href='${kakaoUrl}';">카카오 로그인</button></div>
<div class="Btn Google"><button type="button" onclick="location.href='${kakaoUrl}';">Google 계정으로 로그인</button></div> <div class="Btn Google"><button type="button" onclick="location.href='${googleUrl}';">Google 계정으로 로그인</button></div>
</div> </div>
<div class="row Text"> <div class="row Text">
<p>회원가입하고 <span>대출/열람 서비스</span>를 이용해보세요!</p> <p>회원가입하고 <span>대출/열람 서비스</span>를 이용해보세요!</p>

View File

@ -63,8 +63,8 @@
</div> </div>
<div class="login"> <div class="login">
<div class="Btn Naver"><button type="button" onclick="location.href='${naverUrl}';">네이버로 간편 가입</button></div> <div class="Btn Naver"><button type="button" onclick="location.href='${naverUrl}';">네이버로 간편 가입</button></div>
<div class="Btn Kakao"><button type="button" onclick="location.href='${googleUrl}';">카카오로 회원가입</button></div> <div class="Btn Kakao"><button type="button" onclick="location.href='${kakaoUrl}';">카카오로 회원가입</button></div>
<div class="Btn Google"><button type="button" onclick="location.href='${kakaoUrl}';">Google 계정으로 가입</button></div> <div class="Btn Google"><button type="button" onclick="location.href='${googleUrl}';">Google 계정으로 가입</button></div>
</div> </div>
</div> </div>
</div> </div>