20 lines
515 B
Java
20 lines
515 B
Java
package com.kri.common.webmvc;
|
|
|
|
import java.util.List;
|
|
import lombok.RequiredArgsConstructor;
|
|
import org.springframework.security.web.util.matcher.IpAddressMatcher;
|
|
|
|
@RequiredArgsConstructor
|
|
public class IpAccessControlService {
|
|
|
|
private final KriIpAccessProperties properties;
|
|
|
|
public boolean isAccessible(String ipAddress) {
|
|
List<String> cidrs = properties.getEffectiveCidrs();
|
|
|
|
return cidrs.stream()
|
|
.map(IpAddressMatcher::new)
|
|
.anyMatch(matcher -> matcher.matches(ipAddress));
|
|
}
|
|
}
|