Skip to content

Commit

Permalink
feat: add security permit port
Browse files Browse the repository at this point in the history
  • Loading branch information
redcarrot1 committed Feb 26, 2024
1 parent 72e7684 commit 043517a
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.playkuround.playkuroundserver.domain.auth.token.application.TokenManager;
import com.playkuround.playkuroundserver.global.security.JwtAuthenticationFilter;
import com.playkuround.playkuroundserver.global.security.UserDetailsServiceImpl;
import jakarta.servlet.http.HttpServletRequest;
import lombok.RequiredArgsConstructor;
import org.springframework.boot.autoconfigure.security.servlet.PathRequest;
import org.springframework.context.annotation.Bean;
Expand All @@ -16,6 +17,7 @@
import org.springframework.security.web.SecurityFilterChain;
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
import org.springframework.security.web.util.matcher.RequestMatcher;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.CorsConfigurationSource;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
Expand Down Expand Up @@ -54,7 +56,8 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti
AntPathRequestMatcher.antMatcher(HttpMethod.GET, "/swagger-ui/**"),
AntPathRequestMatcher.antMatcher(HttpMethod.GET, "/swagger-ui.html"),
AntPathRequestMatcher.antMatcher(HttpMethod.GET, "/api-docs/**"),
AntPathRequestMatcher.antMatcher("/actu/**")

checkActPort()
).permitAll()
.requestMatchers(AntPathRequestMatcher.antMatcher("/api/**")).authenticated()
)
Expand All @@ -63,6 +66,10 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti
.build();
}

private RequestMatcher checkActPort() {
return (HttpServletRequest request) -> 8081 == request.getLocalPort();
}

@Bean
public CorsConfigurationSource corsConfigurationSource() {
CorsConfiguration configuration = new CorsConfiguration();
Expand Down

0 comments on commit 043517a

Please sign in to comment.