Remove the now-unused admin logger
This commit is contained in:
parent
949cc9e214
commit
5ad83da4e0
|
@ -1,94 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!--
|
|
||||||
~ Copyright 2022 Signal Messenger, LLC
|
|
||||||
~ SPDX-License-Identifier: AGPL-3.0-only
|
|
||||||
-->
|
|
||||||
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<parent>
|
|
||||||
<artifactId>TextSecureServer</artifactId>
|
|
||||||
<groupId>org.whispersystems.textsecure</groupId>
|
|
||||||
<version>JGITVER</version>
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
<artifactId>event-logger</artifactId>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.google.cloud</groupId>
|
|
||||||
<artifactId>google-cloud-logging</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.jetbrains.kotlin</groupId>
|
|
||||||
<artifactId>kotlin-stdlib</artifactId>
|
|
||||||
<exclusions>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>org.jetbrains</groupId>
|
|
||||||
<!--
|
|
||||||
depends on an outdated version (13.0) for JDK 6 compatibility, but it’s safe to override
|
|
||||||
https://youtrack.jetbrains.com/issue/KT-25047
|
|
||||||
-->
|
|
||||||
<artifactId>annotations</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
</exclusions>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.jetbrains.kotlinx</groupId>
|
|
||||||
<artifactId>kotlinx-serialization-json</artifactId>
|
|
||||||
<version>${kotlinx-serialization.version}</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
<build>
|
|
||||||
<sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
|
|
||||||
<testSourceDirectory>${project.basedir}/src/test/kotlin</testSourceDirectory>
|
|
||||||
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.jetbrains.kotlin</groupId>
|
|
||||||
<artifactId>kotlin-maven-plugin</artifactId>
|
|
||||||
<version>${kotlin.version}</version>
|
|
||||||
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<id>compile</id>
|
|
||||||
<goals>
|
|
||||||
<goal>compile</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
|
|
||||||
<execution>
|
|
||||||
<id>test-compile</id>
|
|
||||||
<goals>
|
|
||||||
<goal>test-compile</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
<configuration>
|
|
||||||
<compilerPlugins>
|
|
||||||
<plugin>kotlinx-serialization</plugin>
|
|
||||||
</compilerPlugins>
|
|
||||||
</configuration>
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.jetbrains.kotlin</groupId>
|
|
||||||
<artifactId>kotlin-maven-serialization</artifactId>
|
|
||||||
<version>${kotlin.version}</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>com.google.cloud.tools</groupId>
|
|
||||||
<artifactId>jib-maven-plugin</artifactId>
|
|
||||||
<configuration>
|
|
||||||
<!-- we don't want jib to execute on this module -->
|
|
||||||
<skip>true</skip>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
|
|
||||||
</project>
|
|
|
@ -1,40 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2022 Signal Messenger, LLC
|
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.signal.event
|
|
||||||
|
|
||||||
import java.util.Collections
|
|
||||||
import kotlinx.serialization.Serializable
|
|
||||||
import kotlinx.serialization.json.Json
|
|
||||||
import kotlinx.serialization.modules.SerializersModule
|
|
||||||
import kotlinx.serialization.modules.polymorphic
|
|
||||||
import kotlinx.serialization.modules.subclass
|
|
||||||
|
|
||||||
val module = SerializersModule {
|
|
||||||
polymorphic(Event::class) {
|
|
||||||
subclass(RemoteConfigSetEvent::class)
|
|
||||||
subclass(RemoteConfigDeleteEvent::class)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
val jsonFormat = Json { serializersModule = module }
|
|
||||||
|
|
||||||
sealed interface Event
|
|
||||||
|
|
||||||
@Serializable
|
|
||||||
data class RemoteConfigSetEvent(
|
|
||||||
val identity: String,
|
|
||||||
val name: String,
|
|
||||||
val percentage: Int,
|
|
||||||
val defaultValue: String? = null,
|
|
||||||
val value: String? = null,
|
|
||||||
val hashKey: String? = null,
|
|
||||||
val uuids: Collection<String> = Collections.emptyList(),
|
|
||||||
) : Event
|
|
||||||
|
|
||||||
@Serializable
|
|
||||||
data class RemoteConfigDeleteEvent(
|
|
||||||
val identity: String,
|
|
||||||
val name: String,
|
|
||||||
) : Event
|
|
|
@ -1,41 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2022 Signal Messenger, LLC
|
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.signal.event
|
|
||||||
|
|
||||||
import com.google.cloud.logging.LogEntry
|
|
||||||
import com.google.cloud.logging.Logging
|
|
||||||
import com.google.cloud.logging.MonitoredResourceUtil
|
|
||||||
import com.google.cloud.logging.Payload.JsonPayload
|
|
||||||
import com.google.cloud.logging.Severity
|
|
||||||
import com.google.protobuf.Struct
|
|
||||||
import com.google.protobuf.util.JsonFormat
|
|
||||||
import kotlinx.serialization.encodeToString
|
|
||||||
|
|
||||||
interface AdminEventLogger {
|
|
||||||
fun logEvent(event: Event, labels: Map<String, String>?)
|
|
||||||
fun logEvent(event: Event) = logEvent(event, null)
|
|
||||||
}
|
|
||||||
|
|
||||||
class NoOpAdminEventLogger : AdminEventLogger {
|
|
||||||
override fun logEvent(event: Event, labels: Map<String, String>?) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
class GoogleCloudAdminEventLogger(private val logging: Logging, private val projectId: String, private val logName: String) : AdminEventLogger {
|
|
||||||
override fun logEvent(event: Event, labels: Map<String, String>?) {
|
|
||||||
val structBuilder = Struct.newBuilder()
|
|
||||||
JsonFormat.parser().merge(jsonFormat.encodeToString(event), structBuilder)
|
|
||||||
val struct = structBuilder.build()
|
|
||||||
|
|
||||||
val logEntryBuilder = LogEntry.newBuilder(JsonPayload.of(struct))
|
|
||||||
.setLogName(logName)
|
|
||||||
.setSeverity(Severity.NOTICE)
|
|
||||||
.setResource(MonitoredResourceUtil.getResource(projectId, "project"));
|
|
||||||
if (labels != null) {
|
|
||||||
logEntryBuilder.setLabels(labels);
|
|
||||||
}
|
|
||||||
logging.write(listOf(logEntryBuilder.build()))
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,35 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2023 Signal Messenger, LLC
|
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.signal.event
|
|
||||||
|
|
||||||
import com.google.cloud.logging.Logging
|
|
||||||
import com.google.cloud.logging.LoggingOptions
|
|
||||||
import org.junit.jupiter.api.Test
|
|
||||||
import org.junit.jupiter.api.assertDoesNotThrow
|
|
||||||
import org.mockito.Mockito.mock
|
|
||||||
|
|
||||||
class GoogleCloudAdminEventLoggerTest {
|
|
||||||
|
|
||||||
@Test
|
|
||||||
fun logEvent() {
|
|
||||||
val logging = mock(Logging::class.java)
|
|
||||||
val logger = GoogleCloudAdminEventLogger(logging, "my-project", "test")
|
|
||||||
|
|
||||||
val event = RemoteConfigDeleteEvent("token", "test")
|
|
||||||
logger.logEvent(event)
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
fun testGetService() {
|
|
||||||
assertDoesNotThrow {
|
|
||||||
// This is a canary for version conflicts between the cloud logging library and protobuf-java
|
|
||||||
LoggingOptions.newBuilder()
|
|
||||||
.setProjectId("test")
|
|
||||||
.build()
|
|
||||||
.getService()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
1
pom.xml
1
pom.xml
|
@ -31,7 +31,6 @@
|
||||||
|
|
||||||
<modules>
|
<modules>
|
||||||
<module>api-doc</module>
|
<module>api-doc</module>
|
||||||
<module>event-logger</module>
|
|
||||||
<module>integration-tests</module>
|
<module>integration-tests</module>
|
||||||
<module>service</module>
|
<module>service</module>
|
||||||
<module>websocket-resources</module>
|
<module>websocket-resources</module>
|
||||||
|
|
|
@ -40,14 +40,6 @@ metrics:
|
||||||
- ^lettuce\..+$
|
- ^lettuce\..+$
|
||||||
reportOnStop: true
|
reportOnStop: true
|
||||||
|
|
||||||
adminEventLoggingConfiguration:
|
|
||||||
credentials: |
|
|
||||||
{
|
|
||||||
"key": "value"
|
|
||||||
}
|
|
||||||
projectId: some-project-id
|
|
||||||
logName: some-log-name
|
|
||||||
|
|
||||||
grpcPort: 8080
|
grpcPort: 8080
|
||||||
|
|
||||||
stripe:
|
stripe:
|
||||||
|
|
|
@ -42,11 +42,6 @@
|
||||||
<artifactId>jakarta.ws.rs-api</artifactId>
|
<artifactId>jakarta.ws.rs-api</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.whispersystems.textsecure</groupId>
|
|
||||||
<artifactId>event-logger</artifactId>
|
|
||||||
<version>${project.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.whispersystems.textsecure</groupId>
|
<groupId>org.whispersystems.textsecure</groupId>
|
||||||
<artifactId>websocket-resources</artifactId>
|
<artifactId>websocket-resources</artifactId>
|
||||||
|
@ -469,6 +464,13 @@
|
||||||
<groupId>com.apollographql.apollo3</groupId>
|
<groupId>com.apollographql.apollo3</groupId>
|
||||||
<artifactId>apollo-api-jvm</artifactId>
|
<artifactId>apollo-api-jvm</artifactId>
|
||||||
<version>3.8.2</version>
|
<version>3.8.2</version>
|
||||||
|
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.jetbrains</groupId>
|
||||||
|
<artifactId>annotations</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
|
@ -16,7 +16,6 @@ import java.util.Set;
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
import org.whispersystems.textsecuregcm.attachments.TusConfiguration;
|
import org.whispersystems.textsecuregcm.attachments.TusConfiguration;
|
||||||
import org.whispersystems.textsecuregcm.configuration.AdminEventLoggingConfiguration;
|
|
||||||
import org.whispersystems.textsecuregcm.configuration.ApnConfiguration;
|
import org.whispersystems.textsecuregcm.configuration.ApnConfiguration;
|
||||||
import org.whispersystems.textsecuregcm.configuration.AppConfigConfiguration;
|
import org.whispersystems.textsecuregcm.configuration.AppConfigConfiguration;
|
||||||
import org.whispersystems.textsecuregcm.configuration.ArtServiceConfiguration;
|
import org.whispersystems.textsecuregcm.configuration.ArtServiceConfiguration;
|
||||||
|
@ -63,11 +62,6 @@ import org.whispersystems.websocket.configuration.WebSocketConfiguration;
|
||||||
/** @noinspection MismatchedQueryAndUpdateOfCollection, WeakerAccess */
|
/** @noinspection MismatchedQueryAndUpdateOfCollection, WeakerAccess */
|
||||||
public class WhisperServerConfiguration extends Configuration {
|
public class WhisperServerConfiguration extends Configuration {
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Valid
|
|
||||||
@JsonProperty
|
|
||||||
private AdminEventLoggingConfiguration adminEventLoggingConfiguration;
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Valid
|
@Valid
|
||||||
@JsonProperty
|
@JsonProperty
|
||||||
|
@ -316,10 +310,6 @@ public class WhisperServerConfiguration extends Configuration {
|
||||||
@JsonProperty
|
@JsonProperty
|
||||||
private LinkDeviceSecretConfiguration linkDevice;
|
private LinkDeviceSecretConfiguration linkDevice;
|
||||||
|
|
||||||
public AdminEventLoggingConfiguration getAdminEventLoggingConfiguration() {
|
|
||||||
return adminEventLoggingConfiguration;
|
|
||||||
}
|
|
||||||
|
|
||||||
public StripeConfiguration getStripe() {
|
public StripeConfiguration getStripe() {
|
||||||
return stripe;
|
return stripe;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,8 +7,6 @@ package org.whispersystems.textsecuregcm;
|
||||||
import static com.codahale.metrics.MetricRegistry.name;
|
import static com.codahale.metrics.MetricRegistry.name;
|
||||||
import static java.util.Objects.requireNonNull;
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
import com.google.auth.oauth2.GoogleCredentials;
|
|
||||||
import com.google.cloud.logging.LoggingOptions;
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
@ -28,9 +26,7 @@ import io.lettuce.core.resource.ClientResources;
|
||||||
import io.micrometer.core.instrument.Metrics;
|
import io.micrometer.core.instrument.Metrics;
|
||||||
import io.micrometer.core.instrument.binder.grpc.MetricCollectingServerInterceptor;
|
import io.micrometer.core.instrument.binder.grpc.MetricCollectingServerInterceptor;
|
||||||
import io.micrometer.core.instrument.binder.jvm.ExecutorServiceMetrics;
|
import io.micrometer.core.instrument.binder.jvm.ExecutorServiceMetrics;
|
||||||
import java.io.ByteArrayInputStream;
|
|
||||||
import java.net.http.HttpClient;
|
import java.net.http.HttpClient;
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.time.Clock;
|
import java.time.Clock;
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
@ -50,8 +46,6 @@ import javax.servlet.ServletRegistration;
|
||||||
import org.eclipse.jetty.servlets.CrossOriginFilter;
|
import org.eclipse.jetty.servlets.CrossOriginFilter;
|
||||||
import org.eclipse.jetty.websocket.server.config.JettyWebSocketServletContainerInitializer;
|
import org.eclipse.jetty.websocket.server.config.JettyWebSocketServletContainerInitializer;
|
||||||
import org.glassfish.jersey.server.ServerProperties;
|
import org.glassfish.jersey.server.ServerProperties;
|
||||||
import org.signal.event.AdminEventLogger;
|
|
||||||
import org.signal.event.GoogleCloudAdminEventLogger;
|
|
||||||
import org.signal.i18n.HeaderControlledResourceBundleLookup;
|
import org.signal.i18n.HeaderControlledResourceBundleLookup;
|
||||||
import org.signal.libsignal.zkgroup.GenericServerSecretParams;
|
import org.signal.libsignal.zkgroup.GenericServerSecretParams;
|
||||||
import org.signal.libsignal.zkgroup.ServerSecretParams;
|
import org.signal.libsignal.zkgroup.ServerSecretParams;
|
||||||
|
@ -473,14 +467,6 @@ public class WhisperServerService extends Application<WhisperServerConfiguration
|
||||||
ScheduledExecutorService subscriptionProcessorRetryExecutor = environment.lifecycle()
|
ScheduledExecutorService subscriptionProcessorRetryExecutor = environment.lifecycle()
|
||||||
.scheduledExecutorService(name(getClass(), "subscriptionProcessorRetry-%d")).threads(1).build();
|
.scheduledExecutorService(name(getClass(), "subscriptionProcessorRetry-%d")).threads(1).build();
|
||||||
|
|
||||||
final AdminEventLogger adminEventLogger = new GoogleCloudAdminEventLogger(
|
|
||||||
LoggingOptions.newBuilder().setProjectId(config.getAdminEventLoggingConfiguration().projectId())
|
|
||||||
.setCredentials(GoogleCredentials.fromStream(new ByteArrayInputStream(
|
|
||||||
config.getAdminEventLoggingConfiguration().credentials().getBytes(StandardCharsets.UTF_8))))
|
|
||||||
.build().getService(),
|
|
||||||
config.getAdminEventLoggingConfiguration().projectId(),
|
|
||||||
config.getAdminEventLoggingConfiguration().logName());
|
|
||||||
|
|
||||||
StripeManager stripeManager = new StripeManager(config.getStripe().apiKey().value(), subscriptionProcessorExecutor,
|
StripeManager stripeManager = new StripeManager(config.getStripe().apiKey().value(), subscriptionProcessorExecutor,
|
||||||
config.getStripe().idempotencyKeyGenerator().value(), config.getStripe().boostDescription(), config.getStripe().supportedCurrenciesByPaymentMethod());
|
config.getStripe().idempotencyKeyGenerator().value(), config.getStripe().boostDescription(), config.getStripe().supportedCurrenciesByPaymentMethod());
|
||||||
BraintreeManager braintreeManager = new BraintreeManager(config.getBraintree().merchantId(),
|
BraintreeManager braintreeManager = new BraintreeManager(config.getBraintree().merchantId(),
|
||||||
|
|
|
@ -1,15 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2022 Signal Messenger, LLC
|
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.whispersystems.textsecuregcm.configuration;
|
|
||||||
|
|
||||||
import javax.validation.constraints.NotBlank;
|
|
||||||
import javax.validation.constraints.NotEmpty;
|
|
||||||
|
|
||||||
public record AdminEventLoggingConfiguration(
|
|
||||||
@NotBlank String credentials,
|
|
||||||
@NotEmpty String projectId,
|
|
||||||
@NotEmpty String logName) {
|
|
||||||
}
|
|
|
@ -5,8 +5,8 @@
|
||||||
|
|
||||||
package org.whispersystems.textsecuregcm.controllers;
|
package org.whispersystems.textsecuregcm.controllers;
|
||||||
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
import org.whispersystems.textsecuregcm.entities.RegistrationServiceSession;
|
import org.whispersystems.textsecuregcm.entities.RegistrationServiceSession;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
|
|
||||||
public class VerificationSessionRateLimitExceededException extends RateLimitExceededException {
|
public class VerificationSessionRateLimitExceededException extends RateLimitExceededException {
|
||||||
|
|
Loading…
Reference in New Issue