Skip to content

Commit

Permalink
Merge pull request #177 from a-romantic-cat/feat177
Browse files Browse the repository at this point in the history
๐Ÿ› oauth2 redirect uri
  • Loading branch information
yerimm99 authored Feb 19, 2024
2 parents 979cdbf + 58a5a85 commit b7efa2f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,14 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
.and()
.authorizeRequests() // ์š”์ฒญ์— ๋Œ€ํ•œ ์ธ์ฆ ์„ค์ •
.antMatchers("/v3/api-docs/**", "/swagger-ui/**", "/swagger-resources/**").permitAll()
.antMatchers("/", "/login/**", "/signUp", "/nangman-collection/",
.antMatchers("/", "/login", "/signUp", "/nangman-collection/",
"/nangman-collection/{nangmanLetterId}/like",
"/nangman-collection/{nangmanLetterId}").permitAll()
.antMatchers("/token/**", "/oauth2/**").permitAll() // ํ† ํฐ ๋ฐœ๊ธ‰์„ ์œ„ํ•œ ๊ฒฝ๋กœ๋Š” ๋ชจ๋‘ ํ—ˆ์šฉ
.antMatchers("/token/**").permitAll() // ํ† ํฐ ๋ฐœ๊ธ‰์„ ์œ„ํ•œ ๊ฒฝ๋กœ๋Š” ๋ชจ๋‘ ํ—ˆ์šฉ
.antMatchers("/css/**", "/images/**", "/js/**", "/favicon.ico", "/h2-console/**").permitAll()
.anyRequest().authenticated() // ๊ทธ ์™ธ์˜ ๋ชจ๋“  ์š”์ฒญ์€ ์ธ์ฆ์ด ํ•„์š”ํ•˜๋‹ค.
.and()
.oauth2Login() // OAuth2 ๋กœ๊ทธ์ธ ์„ค์ •์‹œ์ž‘
.loginPage("https://dev.nangmancat.shop/login")
.userInfoEndpoint().userService(customOAuth2UserService) // OAuth2 ๋กœ๊ทธ์ธ์‹œ ์‚ฌ์šฉ์ž ์ •๋ณด๋ฅผ ๊ฐ€์ ธ์˜ค๋Š” ์—”๋“œํฌ์ธํŠธ์™€ ์‚ฌ์šฉ์ž ์„œ๋น„์Šค๋ฅผ ์„ค์ •
.and()
.failureHandler(oAuth2LoginFailureHandler) // OAuth2 ๋กœ๊ทธ์ธ ์‹คํŒจ์‹œ ์ฒ˜๋ฆฌํ•  ํ•ธ๋“ค๋Ÿฌ๋ฅผ ์ง€์ •ํ•ด์ค€๋‹ค.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class MyAuthenticationFailureHandler implements AuthenticationFailureHand
public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response,
AuthenticationException exception) throws IOException, ServletException {
// ์ธ์ฆ ์‹คํŒจ์‹œ ๋ฉ”์ธ ํŽ˜์ด์ง€๋กœ ์ด๋™
response.sendRedirect("https://dev.nangmancat.shop/");
response.sendRedirect("http://localhost:3000/");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ public void onAuthenticationSuccess(HttpServletRequest request, HttpServletRespo
log.info("jwtToken = {}", token.getAccessToken());

// accessToken์„ ์ฟผ๋ฆฌ์ŠคํŠธ๋ง์— ๋‹ด๋Š” url์„ ๋งŒ๋“ค์–ด์ค€๋‹ค.
String targetUrl = UriComponentsBuilder.fromUriString("https://dev.nangmancat.shop/")
.queryParam("accessToken", token.getAccessToken())
String targetUrl = UriComponentsBuilder.fromUriString("http://localhost:3000/")
// .queryParam("accessToken", token.getAccessToken())
.build()
.encode(StandardCharsets.UTF_8)
.toUriString();
Expand All @@ -72,7 +72,7 @@ public void onAuthenticationSuccess(HttpServletRequest request, HttpServletRespo
} else {

// ํšŒ์›์ด ์กด์žฌํ•˜์ง€ ์•Š์„๊ฒฝ์šฐ, ์„œ๋น„์Šค ์ œ๊ณต์ž์™€ email์„ ์ฟผ๋ฆฌ์ŠคํŠธ๋ง์œผ๋กœ ์ „๋‹ฌํ•˜๋Š” url์„ ๋งŒ๋“ค์–ด์ค€๋‹ค.
String targetUrl = UriComponentsBuilder.fromUriString("https://dev.nangmancat.shop/signUp")
String targetUrl = UriComponentsBuilder.fromUriString("http://localhost:3000/CreateAccount")
.queryParam("email", (String) oAuth2User.getAttribute("email"))
.queryParam("provider", provider)
.build()
Expand Down

0 comments on commit b7efa2f

Please sign in to comment.