-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#37 refactor. Security 모듈을 API 모듈로 이동
- Loading branch information
1 parent
ee83c55
commit ca6cfd9
Showing
63 changed files
with
459 additions
and
1,318 deletions.
There are no files selected for viewing
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
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
2 changes: 1 addition & 1 deletion
2
...m/zipsoon/api/security/dto/AuthToken.java → ...a/com/zipsoon/api/auth/dto/AuthToken.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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package com.zipsoon.api.security.dto; | ||
package com.zipsoon.api.auth.dto; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
|
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,8 @@ | ||
package com.zipsoon.api.auth.dto; | ||
|
||
import jakarta.validation.constraints.Email; | ||
import jakarta.validation.constraints.NotBlank; | ||
|
||
public record LoginRequest( | ||
@NotBlank @Email String email | ||
) {} |
5 changes: 2 additions & 3 deletions
5
...psoon/api/user/dto/UserSignupRequest.java → ...m/zipsoon/api/auth/dto/SignupRequest.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 |
---|---|---|
@@ -1,10 +1,9 @@ | ||
package com.zipsoon.api.user.dto; | ||
package com.zipsoon.api.auth.dto; | ||
|
||
import jakarta.validation.constraints.Email; | ||
import jakarta.validation.constraints.NotBlank; | ||
|
||
public record UserSignupRequest( | ||
public record SignupRequest( | ||
@NotBlank @Email String email, | ||
@NotBlank String password, | ||
@NotBlank String name | ||
) {} |
2 changes: 1 addition & 1 deletion
2
...soon/api/security/model/AuthProvider.java → .../zipsoon/api/auth/model/AuthProvider.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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package com.zipsoon.api.security.model; | ||
package com.zipsoon.api.auth.model; | ||
|
||
public enum AuthProvider { | ||
LOCAL, | ||
|
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
68 changes: 68 additions & 0 deletions
68
api/src/main/java/com/zipsoon/api/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,68 @@ | ||
package com.zipsoon.api.config; | ||
|
||
import com.zipsoon.api.security.filter.JwtAuthenticationFilter; | ||
import com.zipsoon.api.security.handler.JwtAuthenticationEntryPoint; | ||
import com.zipsoon.api.security.jwt.JwtProvider; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.annotation.Import; | ||
import org.springframework.security.config.annotation.web.builders.HttpSecurity; | ||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; | ||
import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer; | ||
import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer; | ||
import org.springframework.security.config.http.SessionCreationPolicy; | ||
import org.springframework.security.web.SecurityFilterChain; | ||
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; | ||
|
||
@Configuration | ||
@EnableWebSecurity | ||
@RequiredArgsConstructor | ||
@Import(MyBatisConfig.class) | ||
public class SecurityConfig { | ||
|
||
private final JwtProvider jwtTokenProvider; | ||
|
||
@Bean | ||
public WebSecurityCustomizer configure() { | ||
return web -> web.ignoring() | ||
.requestMatchers( | ||
"/swagger-ui.html", | ||
"/swagger-ui/**", | ||
"/swagger-resources/**", | ||
"/v3/api-docs/**", | ||
"/webjars/**", | ||
"/error" | ||
); | ||
} | ||
|
||
@Bean | ||
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { | ||
return http | ||
.csrf(AbstractHttpConfigurer::disable) | ||
.httpBasic(AbstractHttpConfigurer::disable) | ||
.formLogin(AbstractHttpConfigurer::disable) | ||
.sessionManagement(session -> session | ||
.sessionCreationPolicy(SessionCreationPolicy.STATELESS) | ||
) | ||
|
||
.authorizeHttpRequests(auth -> auth | ||
.requestMatchers("/api/v1/auth/**").permitAll() | ||
.anyRequest().authenticated() | ||
) | ||
.addFilterBefore( | ||
jwtAuthenticationFilter(), | ||
UsernamePasswordAuthenticationFilter.class | ||
) | ||
.exceptionHandling(ex -> | ||
ex.authenticationEntryPoint(new JwtAuthenticationEntryPoint()) | ||
) | ||
.build(); | ||
} | ||
|
||
@Bean | ||
public JwtAuthenticationFilter jwtAuthenticationFilter() { | ||
return new JwtAuthenticationFilter(jwtTokenProvider); | ||
} | ||
|
||
} |
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
Oops, something went wrong.