Skip to content

Commit

Permalink
Merge branch 'develop' into 'master'
Browse files Browse the repository at this point in the history
Release 0.33.1-SNAPSHOT

See merge request hercules/hercules!197
  • Loading branch information
gnkoshelev committed Jan 9, 2020
2 parents 649cda3 + 8c36794 commit ad9bf19
Show file tree
Hide file tree
Showing 43 changed files with 104 additions and 43 deletions.
2 changes: 1 addition & 1 deletion hercules-application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>hercules</artifactId>
<groupId>ru.kontur.vostok.hercules</groupId>
<version>0.33.0-SNAPSHOT</version>
<version>0.33.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion hercules-auth/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>hercules</artifactId>
<groupId>ru.kontur.vostok.hercules</groupId>
<version>0.33.0-SNAPSHOT</version>
<version>0.33.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package ru.kontur.vostok.hercules.auth;

/**
* The type of right.
*
* @author Vladimir Tsypaev
*/
public enum Right {
READ,
WRITE,
MANAGE;
}
2 changes: 1 addition & 1 deletion hercules-cassandra-sink/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>hercules</artifactId>
<groupId>ru.kontur.vostok.hercules</groupId>
<version>0.33.0-SNAPSHOT</version>
<version>0.33.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion hercules-cassandra-util/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>hercules</artifactId>
<groupId>ru.kontur.vostok.hercules</groupId>
<version>0.33.0-SNAPSHOT</version>
<version>0.33.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion hercules-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>hercules</artifactId>
<groupId>ru.kontur.vostok.hercules</groupId>
<version>0.33.0-SNAPSHOT</version>
<version>0.33.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion hercules-configuration/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>hercules</artifactId>
<groupId>ru.kontur.vostok.hercules</groupId>
<version>0.33.0-SNAPSHOT</version>
<version>0.33.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion hercules-curator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>hercules</artifactId>
<groupId>ru.kontur.vostok.hercules</groupId>
<version>0.33.0-SNAPSHOT</version>
<version>0.33.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion hercules-elastic-sink/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>hercules</artifactId>
<groupId>ru.kontur.vostok.hercules</groupId>
<version>0.33.0-SNAPSHOT</version>
<version>0.33.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 _}.
* <p>
* 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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,13 @@ public void shouldSanitizeIndexName() {
tag("properties", Variant.ofContainer(
Container.builder().
tag("project", Variant.ofString("Project<To,Test>")).
tag("environment", Variant.ofString("DEV")).
tag("environment", Variant.ofString("D.E.V")).
tag("subproject", Variant.ofString(">Ю")).
build())).
build();

Optional<String> 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());
}
}
2 changes: 1 addition & 1 deletion hercules-gate-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>hercules</artifactId>
<groupId>ru.kontur.vostok.hercules</groupId>
<version>0.33.0-SNAPSHOT</version>
<version>0.33.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion hercules-gate/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>hercules</artifactId>
<groupId>ru.kontur.vostok.hercules</groupId>
<version>0.33.0-SNAPSHOT</version>
<version>0.33.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion hercules-graphite-sink/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>hercules</artifactId>
<groupId>ru.kontur.vostok.hercules</groupId>
<version>0.33.0-SNAPSHOT</version>
<version>0.33.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion hercules-health/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>hercules</artifactId>
<groupId>ru.kontur.vostok.hercules</groupId>
<version>0.33.0-SNAPSHOT</version>
<version>0.33.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion hercules-http/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>hercules</artifactId>
<groupId>ru.kontur.vostok.hercules</groupId>
<version>0.33.0-SNAPSHOT</version>
<version>0.33.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion hercules-init/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>hercules</artifactId>
<groupId>ru.kontur.vostok.hercules</groupId>
<version>0.33.0-SNAPSHOT</version>
<version>0.33.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion hercules-json/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>hercules</artifactId>
<groupId>ru.kontur.vostok.hercules</groupId>
<version>0.33.0-SNAPSHOT</version>
<version>0.33.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion hercules-kafka-util/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>hercules</artifactId>
<groupId>ru.kontur.vostok.hercules</groupId>
<version>0.33.0-SNAPSHOT</version>
<version>0.33.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion hercules-management-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>hercules</artifactId>
<groupId>ru.kontur.vostok.hercules</groupId>
<version>0.33.0-SNAPSHOT</version>
<version>0.33.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion hercules-meta/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>hercules</artifactId>
<groupId>ru.kontur.vostok.hercules</groupId>
<version>0.33.0-SNAPSHOT</version>
<version>0.33.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion hercules-partitioner/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>hercules</artifactId>
<groupId>ru.kontur.vostok.hercules</groupId>
<version>0.33.0-SNAPSHOT</version>
<version>0.33.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion hercules-protocol/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>hercules</artifactId>
<groupId>ru.kontur.vostok.hercules</groupId>
<version>0.33.0-SNAPSHOT</version>
<version>0.33.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion hercules-sd/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>hercules</artifactId>
<groupId>ru.kontur.vostok.hercules</groupId>
<version>0.33.0-SNAPSHOT</version>
<version>0.33.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion hercules-sentry-sink/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>hercules</artifactId>
<groupId>ru.kontur.vostok.hercules</groupId>
<version>0.33.0-SNAPSHOT</version>
<version>0.33.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion hercules-sink/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>hercules</artifactId>
<groupId>ru.kontur.vostok.hercules</groupId>
<version>0.33.0-SNAPSHOT</version>
<version>0.33.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion hercules-stream-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>hercules</artifactId>
<groupId>ru.kontur.vostok.hercules</groupId>
<version>0.33.0-SNAPSHOT</version>
<version>0.33.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion hercules-stream-manager/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>hercules</artifactId>
<groupId>ru.kontur.vostok.hercules</groupId>
<version>0.33.0-SNAPSHOT</version>
<version>0.33.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion hercules-stream-sink/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>hercules</artifactId>
<groupId>ru.kontur.vostok.hercules</groupId>
<version>0.33.0-SNAPSHOT</version>
<version>0.33.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion hercules-tags/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>hercules</artifactId>
<groupId>ru.kontur.vostok.hercules</groupId>
<version>0.33.0-SNAPSHOT</version>
<version>0.33.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion hercules-throttling/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>hercules</artifactId>
<groupId>ru.kontur.vostok.hercules</groupId>
<version>0.33.0-SNAPSHOT</version>
<version>0.33.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion hercules-timeline-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>hercules</artifactId>
<groupId>ru.kontur.vostok.hercules</groupId>
<version>0.33.0-SNAPSHOT</version>
<version>0.33.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion hercules-timeline-manager/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>hercules</artifactId>
<groupId>ru.kontur.vostok.hercules</groupId>
<version>0.33.0-SNAPSHOT</version>
<version>0.33.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion hercules-timeline-sink/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>hercules</artifactId>
<groupId>ru.kontur.vostok.hercules</groupId>
<version>0.33.0-SNAPSHOT</version>
<version>0.33.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion hercules-tracing-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>hercules</artifactId>
<groupId>ru.kontur.vostok.hercules</groupId>
<version>0.33.0-SNAPSHOT</version>
<version>0.33.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Loading

0 comments on commit ad9bf19

Please sign in to comment.