-
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.
Browse files
Browse the repository at this point in the history
Feat: 로그인 방식 개선
- Loading branch information
Showing
13 changed files
with
213 additions
and
217 deletions.
There are no files selected for viewing
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
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
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
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
76 changes: 0 additions & 76 deletions
76
src/main/java/univ/goormthon/kongju/global/auth/kakao/controller/KakaoAuthController.java
This file was deleted.
Oops, something went wrong.
20 changes: 0 additions & 20 deletions
20
src/main/java/univ/goormthon/kongju/global/auth/kakao/dto/KakaoProfileInfoResponse.java
This file was deleted.
Oops, something went wrong.
15 changes: 0 additions & 15 deletions
15
src/main/java/univ/goormthon/kongju/global/auth/kakao/dto/KakaoToken.java
This file was deleted.
Oops, something went wrong.
65 changes: 0 additions & 65 deletions
65
src/main/java/univ/goormthon/kongju/global/auth/kakao/service/KakaoAuthService.java
This file was deleted.
Oops, something went wrong.
46 changes: 46 additions & 0 deletions
46
src/main/java/univ/goormthon/kongju/global/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,46 @@ | ||
package univ.goormthon.kongju.global.config; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.security.config.Customizer; | ||
import org.springframework.security.config.annotation.web.builders.HttpSecurity; | ||
import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer; | ||
import org.springframework.security.config.annotation.web.configurers.HeadersConfigurer; | ||
import org.springframework.security.oauth2.jwt.JwtDecoder; | ||
import org.springframework.security.oauth2.jwt.NimbusJwtDecoder; | ||
import org.springframework.security.web.SecurityFilterChain; | ||
|
||
import javax.crypto.SecretKey; | ||
|
||
@Configuration | ||
@RequiredArgsConstructor | ||
public class SecurityConfig { | ||
|
||
private final SecretKey secretKey; | ||
|
||
@Bean | ||
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception { | ||
|
||
// 브라우저 환경이 아니므로 CSRF, BASIC 인증, FormLogin 비활성화 | ||
http.csrf(AbstractHttpConfigurer::disable) | ||
.httpBasic(AbstractHttpConfigurer::disable) | ||
.formLogin(AbstractHttpConfigurer::disable); | ||
|
||
// 인증 경로 설정 | ||
http.authorizeHttpRequests(requests -> requests | ||
.requestMatchers("/h2-console/**","/api/v1/jwt").permitAll() | ||
.anyRequest().authenticated()) | ||
.headers(headers -> headers.frameOptions(HeadersConfigurer.FrameOptionsConfig::disable)); | ||
|
||
// OAuth2 Resource Server 설정 | ||
http.oauth2ResourceServer(oauth2 -> oauth2.jwt(Customizer.withDefaults())); | ||
|
||
return http.build(); | ||
} | ||
|
||
@Bean | ||
public JwtDecoder jwtDecoder() { | ||
return NimbusJwtDecoder.withSecretKey(this.secretKey).build(); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/main/java/univ/goormthon/kongju/global/jwt/controller/JwtController.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,24 @@ | ||
package univ.goormthon.kongju.global.jwt.controller; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
import univ.goormthon.kongju.global.jwt.dto.request.TokenRequest; | ||
import univ.goormthon.kongju.global.jwt.dto.response.TokenResponse; | ||
import univ.goormthon.kongju.global.jwt.service.JwtProvider; | ||
|
||
@RestController | ||
@RequestMapping("/api/v1/jwt") | ||
@RequiredArgsConstructor | ||
public class JwtController { | ||
|
||
private final JwtProvider jwtProvider; | ||
|
||
@PostMapping | ||
public ResponseEntity<TokenResponse> issueJwtToken(@RequestBody TokenRequest tokenRequest) { | ||
return ResponseEntity.ok(jwtProvider.issueJwtToken(tokenRequest)); | ||
} | ||
} |
Oops, something went wrong.