mirror of
https://gitee.com/jmix/cuba.git
synced 2024-12-04 20:28:00 +08:00
PL-9204 Ability to update "trusted client permitted ip list" without server restart
This commit is contained in:
parent
833d84b24b
commit
ce9017a63c
@ -48,6 +48,7 @@ public interface ServerConfig extends Config {
|
||||
String getTrustedClientPassword();
|
||||
|
||||
@Property("cuba.trustedClientPermittedIpList")
|
||||
@Source(type = SourceType.DATABASE)
|
||||
String getTrustedClientPermittedIpList();
|
||||
|
||||
@Property("cuba.security.resetPasswordTemplateBody")
|
||||
|
@ -19,7 +19,6 @@ package com.haulmont.cuba.security.sys;
|
||||
|
||||
import com.haulmont.cuba.core.app.ServerConfig;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.inject.Inject;
|
||||
@ -32,23 +31,17 @@ public class TrustedLoginHandler {
|
||||
@Inject
|
||||
protected ServerConfig serverConfig;
|
||||
|
||||
protected Pattern permittedIpMaskPattern;
|
||||
|
||||
@Inject
|
||||
public void setServerConfig(ServerConfig serverConfig) {
|
||||
String permittedIpList = serverConfig.getTrustedClientPermittedIpList();
|
||||
permittedIpList = convertToRegex(permittedIpList);
|
||||
if (StringUtils.isEmpty(permittedIpList)) {
|
||||
permittedIpList = "127\\.0\\.0\\.1";
|
||||
}
|
||||
permittedIpMaskPattern = Pattern.compile(permittedIpList);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param address ip-address
|
||||
* @return true if address in trusted list
|
||||
*/
|
||||
public boolean checkAddress(String address) {
|
||||
String permittedIpList = serverConfig.getTrustedClientPermittedIpList();
|
||||
permittedIpList = convertToRegex(permittedIpList);
|
||||
if (StringUtils.isEmpty(permittedIpList)) {
|
||||
permittedIpList = "127\\.0\\.0\\.1";
|
||||
}
|
||||
Pattern permittedIpMaskPattern = Pattern.compile(permittedIpList);
|
||||
return permittedIpMaskPattern.matcher(address).matches();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user