Skip to content

Commit

Permalink
refactor(IpAuthenticationFilter): 접근 허용 국가를 프로파일에서 관리하도록 변경 (#379)
Browse files Browse the repository at this point in the history
  • Loading branch information
limehee authored Jun 18, 2024
1 parent 947baf0 commit 5d5b88d
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@
import jakarta.servlet.ServletRequest;
import jakarta.servlet.ServletResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import page.clab.api.global.config.IPInfoConfig;
import page.clab.api.global.util.HttpReqResUtil;

import java.io.IOException;
import java.util.List;
import java.util.Objects;

@Component
Expand All @@ -22,6 +24,9 @@ public class IpAuthenticationFilter implements Filter {

private final IPinfo ipInfo;

@Value("${security.access.allowed-countries}")
private List<String> allowedCountries;

public IpAuthenticationFilter(IPInfoConfig ipInfoConfig) {
ipInfo = ipInfoConfig.ipInfo();
}
Expand All @@ -48,7 +53,7 @@ public void doFilter(ServletRequest request, ServletResponse response, FilterCha

private boolean isNonPermittedCountry(IPResponse ipResponse) {
String country = ipResponse.getCountryCode();
return Objects.nonNull(country) && !country.equals("KR");
return Objects.nonNull(country) && !allowedCountries.contains(country);
}

@Override
Expand Down

0 comments on commit 5d5b88d

Please sign in to comment.