diff --git a/hercules-application/pom.xml b/hercules-application/pom.xml index a13c9783e..8e100572f 100644 --- a/hercules-application/pom.xml +++ b/hercules-application/pom.xml @@ -5,7 +5,7 @@ hercules ru.kontur.vostok.hercules - 0.33.0-SNAPSHOT + 0.33.1-SNAPSHOT 4.0.0 diff --git a/hercules-auth/pom.xml b/hercules-auth/pom.xml index 74d17856a..399bff71b 100644 --- a/hercules-auth/pom.xml +++ b/hercules-auth/pom.xml @@ -3,7 +3,7 @@ hercules ru.kontur.vostok.hercules - 0.33.0-SNAPSHOT + 0.33.1-SNAPSHOT 4.0.0 diff --git a/hercules-auth/src/main/java/ru/kontur/vostok/hercules/auth/AuthProvider.java b/hercules-auth/src/main/java/ru/kontur/vostok/hercules/auth/AuthProvider.java index d3267eeb7..65d167dbf 100644 --- a/hercules-auth/src/main/java/ru/kontur/vostok/hercules/auth/AuthProvider.java +++ b/hercules-auth/src/main/java/ru/kontur/vostok/hercules/auth/AuthProvider.java @@ -135,4 +135,43 @@ public AuthResult authWrite(HttpServerRequest request, String name) { return AuthResult.unknown(); } } + + /** + * Authorize any access from {@code rights} using authentication context of the http request. + * If at least one of right from {@code rights} is authorize success, then return {@link AuthResult#ok()}. + * + * @param request the http request + * @param name the resource name + * @param rights access rights + * @return authorization result + */ + public AuthResult authAny(HttpServerRequest request, String name, Right... rights) { + if (rights.length == 0) { + return AuthResult.unknown(); + } + AuthResult result; + for (Right right : rights) { + if (right == Right.READ) { + result = authRead(request, name); + if (result.isSuccess()) { + return result; + } + continue; + } + if (right == Right.WRITE) { + result = authWrite(request, name); + if (result.isSuccess()) { + return result; + } + continue; + } + if (right == Right.MANAGE) { + result = authManage(request, name); + if (result.isSuccess()) { + return result; + } + } + } + return AuthResult.unknown(); + } } diff --git a/hercules-auth/src/main/java/ru/kontur/vostok/hercules/auth/Right.java b/hercules-auth/src/main/java/ru/kontur/vostok/hercules/auth/Right.java new file mode 100644 index 000000000..0313e8f62 --- /dev/null +++ b/hercules-auth/src/main/java/ru/kontur/vostok/hercules/auth/Right.java @@ -0,0 +1,12 @@ +package ru.kontur.vostok.hercules.auth; + +/** + * The type of right. + * + * @author Vladimir Tsypaev + */ +public enum Right { + READ, + WRITE, + MANAGE; +} diff --git a/hercules-cassandra-sink/pom.xml b/hercules-cassandra-sink/pom.xml index e51073a58..2a7787407 100644 --- a/hercules-cassandra-sink/pom.xml +++ b/hercules-cassandra-sink/pom.xml @@ -5,7 +5,7 @@ hercules ru.kontur.vostok.hercules - 0.33.0-SNAPSHOT + 0.33.1-SNAPSHOT 4.0.0 diff --git a/hercules-cassandra-util/pom.xml b/hercules-cassandra-util/pom.xml index 120020db7..f22b5dbd6 100644 --- a/hercules-cassandra-util/pom.xml +++ b/hercules-cassandra-util/pom.xml @@ -3,7 +3,7 @@ hercules ru.kontur.vostok.hercules - 0.33.0-SNAPSHOT + 0.33.1-SNAPSHOT 4.0.0 diff --git a/hercules-client/pom.xml b/hercules-client/pom.xml index 7149fac07..59f7f8662 100644 --- a/hercules-client/pom.xml +++ b/hercules-client/pom.xml @@ -5,7 +5,7 @@ hercules ru.kontur.vostok.hercules - 0.33.0-SNAPSHOT + 0.33.1-SNAPSHOT 4.0.0 diff --git a/hercules-configuration/pom.xml b/hercules-configuration/pom.xml index e6fdc6966..5d38be8cb 100644 --- a/hercules-configuration/pom.xml +++ b/hercules-configuration/pom.xml @@ -3,7 +3,7 @@ hercules ru.kontur.vostok.hercules - 0.33.0-SNAPSHOT + 0.33.1-SNAPSHOT 4.0.0 diff --git a/hercules-curator/pom.xml b/hercules-curator/pom.xml index e52115571..e75aa2638 100644 --- a/hercules-curator/pom.xml +++ b/hercules-curator/pom.xml @@ -5,7 +5,7 @@ hercules ru.kontur.vostok.hercules - 0.33.0-SNAPSHOT + 0.33.1-SNAPSHOT 4.0.0 diff --git a/hercules-elastic-sink/pom.xml b/hercules-elastic-sink/pom.xml index 18e35b684..c0c81f781 100644 --- a/hercules-elastic-sink/pom.xml +++ b/hercules-elastic-sink/pom.xml @@ -5,7 +5,7 @@ hercules ru.kontur.vostok.hercules - 0.33.0-SNAPSHOT + 0.33.1-SNAPSHOT 4.0.0 diff --git a/hercules-elastic-sink/src/main/java/ru/kontur/vostok/hercules/elastic/sink/index/IndexResolver.java b/hercules-elastic-sink/src/main/java/ru/kontur/vostok/hercules/elastic/sink/index/IndexResolver.java index 5862d0772..ffb1ebbd1 100644 --- a/hercules-elastic-sink/src/main/java/ru/kontur/vostok/hercules/elastic/sink/index/IndexResolver.java +++ b/hercules-elastic-sink/src/main/java/ru/kontur/vostok/hercules/elastic/sink/index/IndexResolver.java @@ -90,8 +90,16 @@ private static String getFormattedDate(Event event) { return DATE_FORMATTER.format(TimeUtil.unixTicksToInstant(event.getTimestamp())); } - private static final Pattern ILLEGAL_CHARS = Pattern.compile("[^-a-zA-Z0-9_]"); - + private static final Pattern ILLEGAL_CHARS = Pattern.compile("[^-a-zA-Z0-9_.]"); + + /** + * Replace illegal characters with underscore {@code _}. + *

+ * Illegal character is any character which is not alphanumeric, minus sign {@code -}, underscore {@code _} or dot {@code .}. + * + * @param s the string + * @return the sanitized string + */ private static String sanitize(String s) { return ILLEGAL_CHARS.matcher(s).replaceAll("_"). toLowerCase(); diff --git a/hercules-elastic-sink/src/test/java/ru/kontur/vostok/hercules/elastic/sink/index/IndexResolverTest.java b/hercules-elastic-sink/src/test/java/ru/kontur/vostok/hercules/elastic/sink/index/IndexResolverTest.java index 6c945c433..753c0c480 100644 --- a/hercules-elastic-sink/src/test/java/ru/kontur/vostok/hercules/elastic/sink/index/IndexResolverTest.java +++ b/hercules-elastic-sink/src/test/java/ru/kontur/vostok/hercules/elastic/sink/index/IndexResolverTest.java @@ -93,13 +93,13 @@ public void shouldSanitizeIndexName() { tag("properties", Variant.ofContainer( Container.builder(). tag("project", Variant.ofString("Project")). - tag("environment", Variant.ofString("DEV")). + tag("environment", Variant.ofString("D.E.V")). tag("subproject", Variant.ofString(">Ю")). build())). build(); Optional index = indexResolver.resolve(event); Assert.assertTrue(index.isPresent()); - Assert.assertEquals("project_to_test_-dev-__-2019.12.01", index.get()); + Assert.assertEquals("project_to_test_-d.e.v-__-2019.12.01", index.get()); } } diff --git a/hercules-gate-client/pom.xml b/hercules-gate-client/pom.xml index 2c184a7c1..5cbb40867 100644 --- a/hercules-gate-client/pom.xml +++ b/hercules-gate-client/pom.xml @@ -3,7 +3,7 @@ hercules ru.kontur.vostok.hercules - 0.33.0-SNAPSHOT + 0.33.1-SNAPSHOT 4.0.0 diff --git a/hercules-gate/pom.xml b/hercules-gate/pom.xml index eca85524d..efaee9bf0 100644 --- a/hercules-gate/pom.xml +++ b/hercules-gate/pom.xml @@ -3,7 +3,7 @@ hercules ru.kontur.vostok.hercules - 0.33.0-SNAPSHOT + 0.33.1-SNAPSHOT 4.0.0 diff --git a/hercules-graphite-sink/pom.xml b/hercules-graphite-sink/pom.xml index 39547821e..2a19b1991 100644 --- a/hercules-graphite-sink/pom.xml +++ b/hercules-graphite-sink/pom.xml @@ -3,7 +3,7 @@ hercules ru.kontur.vostok.hercules - 0.33.0-SNAPSHOT + 0.33.1-SNAPSHOT 4.0.0 diff --git a/hercules-health/pom.xml b/hercules-health/pom.xml index 21c587416..dd2018b95 100644 --- a/hercules-health/pom.xml +++ b/hercules-health/pom.xml @@ -3,7 +3,7 @@ hercules ru.kontur.vostok.hercules - 0.33.0-SNAPSHOT + 0.33.1-SNAPSHOT 4.0.0 diff --git a/hercules-http/pom.xml b/hercules-http/pom.xml index 5077154e1..3f3740502 100644 --- a/hercules-http/pom.xml +++ b/hercules-http/pom.xml @@ -3,7 +3,7 @@ hercules ru.kontur.vostok.hercules - 0.33.0-SNAPSHOT + 0.33.1-SNAPSHOT 4.0.0 diff --git a/hercules-init/pom.xml b/hercules-init/pom.xml index 288907299..65c8f4c70 100644 --- a/hercules-init/pom.xml +++ b/hercules-init/pom.xml @@ -3,7 +3,7 @@ hercules ru.kontur.vostok.hercules - 0.33.0-SNAPSHOT + 0.33.1-SNAPSHOT 4.0.0 diff --git a/hercules-json/pom.xml b/hercules-json/pom.xml index 8f8c72bd2..e57b3ef0e 100644 --- a/hercules-json/pom.xml +++ b/hercules-json/pom.xml @@ -5,7 +5,7 @@ hercules ru.kontur.vostok.hercules - 0.33.0-SNAPSHOT + 0.33.1-SNAPSHOT 4.0.0 diff --git a/hercules-kafka-util/pom.xml b/hercules-kafka-util/pom.xml index 07cb5048f..9895504d4 100644 --- a/hercules-kafka-util/pom.xml +++ b/hercules-kafka-util/pom.xml @@ -3,7 +3,7 @@ hercules ru.kontur.vostok.hercules - 0.33.0-SNAPSHOT + 0.33.1-SNAPSHOT 4.0.0 diff --git a/hercules-management-api/pom.xml b/hercules-management-api/pom.xml index 0e076a73e..4d89e01e6 100644 --- a/hercules-management-api/pom.xml +++ b/hercules-management-api/pom.xml @@ -3,7 +3,7 @@ hercules ru.kontur.vostok.hercules - 0.33.0-SNAPSHOT + 0.33.1-SNAPSHOT 4.0.0 diff --git a/hercules-management-api/src/main/java/ru/kontur/vostok/hercules/management/api/stream/InfoStreamHandler.java b/hercules-management-api/src/main/java/ru/kontur/vostok/hercules/management/api/stream/InfoStreamHandler.java index 1ae2e9916..e7a3c4edf 100644 --- a/hercules-management-api/src/main/java/ru/kontur/vostok/hercules/management/api/stream/InfoStreamHandler.java +++ b/hercules-management-api/src/main/java/ru/kontur/vostok/hercules/management/api/stream/InfoStreamHandler.java @@ -4,6 +4,7 @@ import org.slf4j.LoggerFactory; import ru.kontur.vostok.hercules.auth.AuthProvider; import ru.kontur.vostok.hercules.auth.AuthResult; +import ru.kontur.vostok.hercules.auth.Right; import ru.kontur.vostok.hercules.curator.exception.CuratorException; import ru.kontur.vostok.hercules.http.HttpServerRequest; import ru.kontur.vostok.hercules.http.HttpStatusCodes; @@ -44,7 +45,7 @@ public void handle(HttpServerRequest request) { return; } - AuthResult authResult = authProvider.authManage(request, streamName.get()); + AuthResult authResult = authProvider.authAny(request, streamName.get(), Right.READ, Right.MANAGE); if (!authResult.isSuccess()) { if (authResult.isUnknown()) { request.complete(HttpStatusCodes.UNAUTHORIZED); diff --git a/hercules-meta/pom.xml b/hercules-meta/pom.xml index 22b0c1a4d..b69022770 100644 --- a/hercules-meta/pom.xml +++ b/hercules-meta/pom.xml @@ -3,7 +3,7 @@ hercules ru.kontur.vostok.hercules - 0.33.0-SNAPSHOT + 0.33.1-SNAPSHOT 4.0.0 diff --git a/hercules-partitioner/pom.xml b/hercules-partitioner/pom.xml index 65cd9eb0f..f4b4ed30e 100644 --- a/hercules-partitioner/pom.xml +++ b/hercules-partitioner/pom.xml @@ -3,7 +3,7 @@ hercules ru.kontur.vostok.hercules - 0.33.0-SNAPSHOT + 0.33.1-SNAPSHOT 4.0.0 diff --git a/hercules-protocol/pom.xml b/hercules-protocol/pom.xml index a1b6cea03..a62f8038c 100644 --- a/hercules-protocol/pom.xml +++ b/hercules-protocol/pom.xml @@ -3,7 +3,7 @@ hercules ru.kontur.vostok.hercules - 0.33.0-SNAPSHOT + 0.33.1-SNAPSHOT 4.0.0 diff --git a/hercules-sd/pom.xml b/hercules-sd/pom.xml index b44c06adf..18a4df1b8 100644 --- a/hercules-sd/pom.xml +++ b/hercules-sd/pom.xml @@ -5,7 +5,7 @@ hercules ru.kontur.vostok.hercules - 0.33.0-SNAPSHOT + 0.33.1-SNAPSHOT 4.0.0 diff --git a/hercules-sentry-sink/pom.xml b/hercules-sentry-sink/pom.xml index 38583b011..73107369b 100644 --- a/hercules-sentry-sink/pom.xml +++ b/hercules-sentry-sink/pom.xml @@ -3,7 +3,7 @@ hercules ru.kontur.vostok.hercules - 0.33.0-SNAPSHOT + 0.33.1-SNAPSHOT 4.0.0 diff --git a/hercules-sink/pom.xml b/hercules-sink/pom.xml index 643a2e680..6e727a985 100644 --- a/hercules-sink/pom.xml +++ b/hercules-sink/pom.xml @@ -5,7 +5,7 @@ hercules ru.kontur.vostok.hercules - 0.33.0-SNAPSHOT + 0.33.1-SNAPSHOT 4.0.0 diff --git a/hercules-stream-api/pom.xml b/hercules-stream-api/pom.xml index 693fadf8e..3bf1f5cee 100644 --- a/hercules-stream-api/pom.xml +++ b/hercules-stream-api/pom.xml @@ -3,7 +3,7 @@ hercules ru.kontur.vostok.hercules - 0.33.0-SNAPSHOT + 0.33.1-SNAPSHOT 4.0.0 diff --git a/hercules-stream-manager/pom.xml b/hercules-stream-manager/pom.xml index c5bb738fe..8a6b787a9 100644 --- a/hercules-stream-manager/pom.xml +++ b/hercules-stream-manager/pom.xml @@ -3,7 +3,7 @@ hercules ru.kontur.vostok.hercules - 0.33.0-SNAPSHOT + 0.33.1-SNAPSHOT 4.0.0 diff --git a/hercules-stream-sink/pom.xml b/hercules-stream-sink/pom.xml index 094bec764..c80196736 100644 --- a/hercules-stream-sink/pom.xml +++ b/hercules-stream-sink/pom.xml @@ -3,7 +3,7 @@ hercules ru.kontur.vostok.hercules - 0.33.0-SNAPSHOT + 0.33.1-SNAPSHOT 4.0.0 diff --git a/hercules-tags/pom.xml b/hercules-tags/pom.xml index 640e16746..6c1ca1934 100644 --- a/hercules-tags/pom.xml +++ b/hercules-tags/pom.xml @@ -3,7 +3,7 @@ hercules ru.kontur.vostok.hercules - 0.33.0-SNAPSHOT + 0.33.1-SNAPSHOT 4.0.0 diff --git a/hercules-throttling/pom.xml b/hercules-throttling/pom.xml index 343275572..0cda441aa 100644 --- a/hercules-throttling/pom.xml +++ b/hercules-throttling/pom.xml @@ -3,7 +3,7 @@ hercules ru.kontur.vostok.hercules - 0.33.0-SNAPSHOT + 0.33.1-SNAPSHOT 4.0.0 diff --git a/hercules-timeline-api/pom.xml b/hercules-timeline-api/pom.xml index 3047f6cb8..534de6155 100644 --- a/hercules-timeline-api/pom.xml +++ b/hercules-timeline-api/pom.xml @@ -3,7 +3,7 @@ hercules ru.kontur.vostok.hercules - 0.33.0-SNAPSHOT + 0.33.1-SNAPSHOT 4.0.0 diff --git a/hercules-timeline-manager/pom.xml b/hercules-timeline-manager/pom.xml index 552d36077..cf1bf553b 100644 --- a/hercules-timeline-manager/pom.xml +++ b/hercules-timeline-manager/pom.xml @@ -3,7 +3,7 @@ hercules ru.kontur.vostok.hercules - 0.33.0-SNAPSHOT + 0.33.1-SNAPSHOT 4.0.0 diff --git a/hercules-timeline-sink/pom.xml b/hercules-timeline-sink/pom.xml index 5743eb0d8..f05677892 100644 --- a/hercules-timeline-sink/pom.xml +++ b/hercules-timeline-sink/pom.xml @@ -3,7 +3,7 @@ hercules ru.kontur.vostok.hercules - 0.33.0-SNAPSHOT + 0.33.1-SNAPSHOT 4.0.0 diff --git a/hercules-tracing-api/pom.xml b/hercules-tracing-api/pom.xml index b2d0ac95d..0762e6a0d 100644 --- a/hercules-tracing-api/pom.xml +++ b/hercules-tracing-api/pom.xml @@ -5,7 +5,7 @@ hercules ru.kontur.vostok.hercules - 0.33.0-SNAPSHOT + 0.33.1-SNAPSHOT 4.0.0 diff --git a/hercules-tracing-sink/pom.xml b/hercules-tracing-sink/pom.xml index 6018ed35e..b54fbc806 100644 --- a/hercules-tracing-sink/pom.xml +++ b/hercules-tracing-sink/pom.xml @@ -5,7 +5,7 @@ hercules ru.kontur.vostok.hercules - 0.33.0-SNAPSHOT + 0.33.1-SNAPSHOT 4.0.0 diff --git a/hercules-undertow-util/pom.xml b/hercules-undertow-util/pom.xml index 4ca9fbf8c..1f75dbd6d 100644 --- a/hercules-undertow-util/pom.xml +++ b/hercules-undertow-util/pom.xml @@ -3,7 +3,7 @@ hercules ru.kontur.vostok.hercules - 0.33.0-SNAPSHOT + 0.33.1-SNAPSHOT 4.0.0 diff --git a/hercules-util/pom.xml b/hercules-util/pom.xml index d3ec22663..b8cfef7b8 100644 --- a/hercules-util/pom.xml +++ b/hercules-util/pom.xml @@ -3,7 +3,7 @@ hercules ru.kontur.vostok.hercules - 0.33.0-SNAPSHOT + 0.33.1-SNAPSHOT 4.0.0 diff --git a/hercules-util/src/main/java/ru/kontur/vostok/hercules/util/text/CharUtil.java b/hercules-util/src/main/java/ru/kontur/vostok/hercules/util/text/CharUtil.java index 7847d9081..29c344abb 100644 --- a/hercules-util/src/main/java/ru/kontur/vostok/hercules/util/text/CharUtil.java +++ b/hercules-util/src/main/java/ru/kontur/vostok/hercules/util/text/CharUtil.java @@ -7,6 +7,7 @@ public final class CharUtil { public static boolean isAlphaNumeric(char c) { return isLatin(c) || isDigit(c); } + public static boolean isLatin(char c) { return isUpperCaseLatin(c) || isLowerCaseLatin(c); } diff --git a/hercules-uuid/pom.xml b/hercules-uuid/pom.xml index 5fadbba9f..cede90bcf 100644 --- a/hercules-uuid/pom.xml +++ b/hercules-uuid/pom.xml @@ -3,7 +3,7 @@ hercules ru.kontur.vostok.hercules - 0.33.0-SNAPSHOT + 0.33.1-SNAPSHOT 4.0.0 diff --git a/pom.xml b/pom.xml index bda92eb2a..2d8bcca60 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ ru.kontur.vostok.hercules hercules pom - 0.33.0-SNAPSHOT + 0.33.1-SNAPSHOT UTF-8 @@ -14,7 +14,7 @@ 1.8 1.8 - 0.33.0-SNAPSHOT + 0.33.1-SNAPSHOT 2.2.0 3.4.13