fix: allow proxied gb32960 platform login ips
Some checks failed
ci/woodpecker/push/woodpecker Pipeline was canceled
Some checks failed
ci/woodpecker/push/woodpecker Pipeline was canceled
This commit is contained in:
@@ -4,6 +4,7 @@ import com.lingniu.ingest.protocol.gb32960.config.Gb32960Properties;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -64,6 +65,7 @@ public final class Gb32960PlatformAuthorizer {
|
|||||||
? Set.of()
|
? Set.of()
|
||||||
: entry.getAllowedIps().stream()
|
: entry.getAllowedIps().stream()
|
||||||
.filter(Objects::nonNull)
|
.filter(Objects::nonNull)
|
||||||
|
.flatMap(value -> Arrays.stream(value.split(",")))
|
||||||
.map(String::trim)
|
.map(String::trim)
|
||||||
.filter(ip -> !ip.isBlank())
|
.filter(ip -> !ip.isBlank())
|
||||||
.collect(java.util.stream.Collectors.toSet());
|
.collect(java.util.stream.Collectors.toSet());
|
||||||
|
|||||||
@@ -61,6 +61,21 @@ class Gb32960AccessServiceTest {
|
|||||||
.accepted()).isTrue();
|
.accepted()).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void authenticatePlatformLogin_acceptsCommaSeparatedAllowedIps() {
|
||||||
|
Gb32960Properties.Auth auth = new Gb32960Properties.Auth();
|
||||||
|
Gb32960Properties.Auth.Platform platform = new Gb32960Properties.Auth.Platform();
|
||||||
|
platform.setUsername("lingniu");
|
||||||
|
platform.setPassword("secret");
|
||||||
|
platform.setAllowedIps(List.of("115.29.187.205,127.0.0.1"));
|
||||||
|
auth.setPlatforms(List.of(platform));
|
||||||
|
|
||||||
|
Gb32960PlatformAuthorizer authorizer = new Gb32960PlatformAuthorizer(auth.getPlatforms());
|
||||||
|
|
||||||
|
assertThat(authorizer.authenticate("lingniu", "secret", "127.0.0.1")
|
||||||
|
.accepted()).isTrue();
|
||||||
|
}
|
||||||
|
|
||||||
private static Gb32960AccessService newService(boolean vinAuthEnabled) {
|
private static Gb32960AccessService newService(boolean vinAuthEnabled) {
|
||||||
Gb32960Properties.Auth auth = new Gb32960Properties.Auth();
|
Gb32960Properties.Auth auth = new Gb32960Properties.Auth();
|
||||||
auth.setEnabled(vinAuthEnabled);
|
auth.setEnabled(vinAuthEnabled);
|
||||||
|
|||||||
Reference in New Issue
Block a user