-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into feature/#18
- Loading branch information
Showing
122 changed files
with
3,857 additions
and
600 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Empty file.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
Empty file.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file removed
BIN
-917 Bytes
out/production/classes/com/umc/DongnaeFriend/DongnaeFriendApplication.class
Binary file not shown.
Binary file removed
BIN
-645 Bytes
out/production/classes/com/umc/DongnaeFriend/HealthCheckController.class
Binary file not shown.
Binary file removed
BIN
-3.56 KB
out/production/classes/com/umc/DongnaeFriend/domain/user/entity/User.class
Binary file not shown.
This file was deleted.
Oops, something went wrong.
Binary file removed
BIN
-568 Bytes
out/test/classes/com/umc/DongnaeFriend/DongnaeFriendApplicationTests.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
85 changes: 85 additions & 0 deletions
85
src/main/java/com/umc/DongnaeFriend/KakaoTokenController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
package com.umc.DongnaeFriend; | ||
|
||
import com.fasterxml.jackson.core.type.TypeReference; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.umc.DongnaeFriend.domain.user.dto.UserDto; | ||
import com.umc.DongnaeFriend.domain.user.service.KakaoService; | ||
import com.umc.DongnaeFriend.domain.user.service.UserService; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.ui.Model; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
|
||
import javax.servlet.http.HttpServletResponse; | ||
import java.io.BufferedReader; | ||
import java.io.IOException; | ||
import java.io.InputStreamReader; | ||
import java.net.HttpURLConnection; | ||
import java.net.URL; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
@Slf4j | ||
@Controller | ||
@RequestMapping("") | ||
public class KakaoTokenController { | ||
|
||
@Autowired | ||
private UserService userService; | ||
|
||
@Autowired | ||
private KakaoService kakaoService; | ||
|
||
@GetMapping("/kakao") | ||
public String kakologin(Model model, HttpServletResponse response) { | ||
response.setContentType(MediaType.TEXT_HTML_VALUE); | ||
|
||
return "html/index"; | ||
} | ||
|
||
@GetMapping("/callback") | ||
public String callback(Model model, @RequestParam("code") String code) throws IOException { | ||
|
||
try { | ||
//------kakao POST 요청------ | ||
String reqURL = "https://kauth.kakao.com/oauth/token?grant_type=authorization_code&client_id=1ad317e194df665ca44dcb82d11a7093&code=" + code; | ||
URL url = new URL(reqURL); | ||
HttpURLConnection conn = (HttpURLConnection) url.openConnection(); | ||
conn.setRequestMethod("POST"); | ||
|
||
|
||
BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream())); | ||
|
||
String line = ""; | ||
String result = ""; | ||
|
||
while ((line = br.readLine()) != null) { | ||
result += line; | ||
} | ||
|
||
ObjectMapper objectMapper = new ObjectMapper(); | ||
Map<String, Object> jsonMap = objectMapper.readValue(result, new TypeReference<Map<String, Object>>() { | ||
}); | ||
|
||
String accessToken = (String) jsonMap.get("access_token"); | ||
|
||
//-------------------------------------------------서버 로그인---------------------------------------------------- | ||
|
||
HashMap<String, Object> userInfo = kakaoService.getUserInfo(accessToken); | ||
UserDto.Response response = userService.userValidation(userInfo); | ||
|
||
model.addAttribute("token","Bearer "+ response.getAccessToken()); | ||
|
||
return "html/token"; | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
return null; | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.umc.DongnaeFriend.config; | ||
|
||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Configuration | ||
public class JwtConfig { | ||
|
||
@Value("${jwt.secret-key}") | ||
public String SECRET_KEY; | ||
|
||
} |
20 changes: 20 additions & 0 deletions
20
src/main/java/com/umc/DongnaeFriend/config/QuerydslConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.umc.DongnaeFriend.config; | ||
|
||
import com.querydsl.jpa.impl.JPAQueryFactory; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
import javax.persistence.EntityManager; | ||
import javax.persistence.PersistenceContext; | ||
|
||
@Configuration | ||
public class QuerydslConfiguration { | ||
|
||
@PersistenceContext | ||
private EntityManager entityManager; | ||
|
||
@Bean | ||
public JPAQueryFactory jpaQueryFactory() { | ||
return new JPAQueryFactory(entityManager); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
src/main/java/com/umc/DongnaeFriend/config/SecurityConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.umc.DongnaeFriend.config; | ||
|
||
|
||
import com.umc.DongnaeFriend.global.security.JwtTokenFilter; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.security.config.annotation.web.builders.HttpSecurity; | ||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; | ||
import org.springframework.security.config.http.SessionCreationPolicy; | ||
|
||
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; | ||
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; | ||
|
||
@EnableWebSecurity | ||
public class SecurityConfig extends WebSecurityConfigurerAdapter { | ||
|
||
@Autowired | ||
private JwtTokenFilter jwtTokenFilter; | ||
|
||
|
||
@Override | ||
protected void configure(HttpSecurity http) throws Exception { | ||
http.csrf().disable() | ||
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS) | ||
.and() | ||
.authorizeRequests() | ||
.antMatchers("/user/login").permitAll() // 인증 없이 접근 허용하는 URL | ||
.antMatchers("/user/reissuance").permitAll() // 인증 없이 접근 허용하는 URL | ||
.antMatchers("/kakao").permitAll() // 카카오 토큰 추출(임시) | ||
.antMatchers("/callback").permitAll() // 카카오 토큰 추출(임시) | ||
.anyRequest().authenticated(); // 그 외의 URL은 인증 필요 | ||
http.addFilterBefore(jwtTokenFilter, UsernamePasswordAuthenticationFilter.class); | ||
} | ||
|
||
// 나머지 코드는 이전 예제와 동일 | ||
} |
Oops, something went wrong.