Skip to content

Commit aa1ff25

Browse files
eager-signaljon-signal
authored andcommitted
Enforce AccountAttributes#isUnrestrictedUakValid
1 parent 1301bfd commit aa1ff25

2 files changed

Lines changed: 1 addition & 22 deletions

File tree

service/src/main/java/org/whispersystems/textsecuregcm/entities/AccountAttributes.java

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,19 @@
88
import com.fasterxml.jackson.annotation.JsonUnwrapped;
99
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
1010
import com.google.common.annotations.VisibleForTesting;
11-
import io.micrometer.core.instrument.Metrics;
1211
import io.swagger.v3.oas.annotations.media.Schema;
1312
import jakarta.validation.Valid;
1413
import jakarta.validation.constraints.AssertTrue;
1514
import java.util.Optional;
1615
import java.util.Set;
1716
import javax.annotation.Nullable;
1817
import org.whispersystems.textsecuregcm.auth.UnidentifiedAccessUtil;
19-
import org.whispersystems.textsecuregcm.metrics.MetricsUtil;
2018
import org.whispersystems.textsecuregcm.storage.DeviceCapability;
2119
import org.whispersystems.textsecuregcm.util.ByteArrayAdapter;
2220
import org.whispersystems.textsecuregcm.util.ExactlySize;
2321

2422
public class AccountAttributes {
2523

26-
private static final String UAK_VALIDATION_COUNTER_NAME = MetricsUtil.name(AccountAttributes.class, "uakValidation");
27-
2824
@JsonUnwrapped
2925
@Valid
3026
private DeviceAttributes deviceAttributes;
@@ -132,23 +128,10 @@ public AccountAttributes setUnrestrictedUnidentifiedAccess(final boolean unrestr
132128
return this;
133129
}
134130

135-
@VisibleForTesting
136-
public static final boolean ENFORCE_VALID_UNRESTRICTED_UAK = false;
137-
138131
@AssertTrue
139132
@Schema(hidden = true)
140133
public boolean isUnrestrictedUakValid() {
141134

142-
final boolean valid = unrestrictedUnidentifiedAccess ||
143-
(!unrestrictedUnidentifiedAccess && (unidentifiedAccessKey != null
144-
&& unidentifiedAccessKey.length == 16));
145-
146-
Metrics.counter(UAK_VALIDATION_COUNTER_NAME,
147-
"valid", String.valueOf(valid),
148-
"unrestricted", String.valueOf(unrestrictedUnidentifiedAccess)
149-
).increment();
150-
151-
// initially, only gather metrics
152-
return true;
135+
return unrestrictedUnidentifiedAccess || (unidentifiedAccessKey != null && unidentifiedAccessKey.length == 16);
153136
}
154137
}

service/src/test/java/org/whispersystems/textsecuregcm/controllers/AccountControllerTest.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
import org.glassfish.jersey.server.ServerProperties;
4949
import org.glassfish.jersey.test.grizzly.GrizzlyWebTestContainerFactory;
5050
import org.junit.jupiter.api.AfterEach;
51-
import org.junit.jupiter.api.Assumptions;
5251
import org.junit.jupiter.api.BeforeEach;
5352
import org.junit.jupiter.api.Test;
5453
import org.junit.jupiter.api.extension.ExtendWith;
@@ -782,9 +781,6 @@ void testDeleteUsernameBadAuth() {
782781
@MethodSource
783782
void testSetAccountAttributesUnrestrictedUnidentifiedAccess(final boolean unrestrictedUnidentifiedAccess, final byte[] unidentifiedAccessKey, final int expectedStatus) {
784783

785-
// This test is only valid when validations are enforced
786-
Assumptions.assumeTrue(AccountAttributes.ENFORCE_VALID_UNRESTRICTED_UAK);
787-
788784
try (final Response response = resources.getJerseyTest()
789785
.target("/v1/accounts/attributes/")
790786
.request()

0 commit comments

Comments
 (0)