Revert "Count requests with missing device capabilities"
This reverts commit 6cdf8ebd2c
.
This commit is contained in:
parent
44145073f1
commit
2054ab2771
|
@ -8,8 +8,6 @@ import com.google.common.annotations.VisibleForTesting;
|
||||||
import com.google.common.net.HttpHeaders;
|
import com.google.common.net.HttpHeaders;
|
||||||
import io.dropwizard.auth.Auth;
|
import io.dropwizard.auth.Auth;
|
||||||
import io.lettuce.core.SetArgs;
|
import io.lettuce.core.SetArgs;
|
||||||
import io.micrometer.core.instrument.Metrics;
|
|
||||||
import io.micrometer.core.instrument.Tags;
|
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.headers.Header;
|
import io.swagger.v3.oas.annotations.headers.Header;
|
||||||
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||||
|
@ -61,8 +59,6 @@ import org.whispersystems.textsecuregcm.entities.LinkDeviceRequest;
|
||||||
import org.whispersystems.textsecuregcm.entities.PreKeySignatureValidator;
|
import org.whispersystems.textsecuregcm.entities.PreKeySignatureValidator;
|
||||||
import org.whispersystems.textsecuregcm.identity.IdentityType;
|
import org.whispersystems.textsecuregcm.identity.IdentityType;
|
||||||
import org.whispersystems.textsecuregcm.limits.RateLimiters;
|
import org.whispersystems.textsecuregcm.limits.RateLimiters;
|
||||||
import org.whispersystems.textsecuregcm.metrics.MetricsUtil;
|
|
||||||
import org.whispersystems.textsecuregcm.metrics.UserAgentTagUtil;
|
|
||||||
import org.whispersystems.textsecuregcm.redis.FaultTolerantRedisCluster;
|
import org.whispersystems.textsecuregcm.redis.FaultTolerantRedisCluster;
|
||||||
import org.whispersystems.textsecuregcm.storage.Account;
|
import org.whispersystems.textsecuregcm.storage.Account;
|
||||||
import org.whispersystems.textsecuregcm.storage.AccountsManager;
|
import org.whispersystems.textsecuregcm.storage.AccountsManager;
|
||||||
|
@ -96,9 +92,6 @@ public class DeviceController {
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
static final Duration TOKEN_EXPIRATION_DURATION = Duration.ofMinutes(10);
|
static final Duration TOKEN_EXPIRATION_DURATION = Duration.ofMinutes(10);
|
||||||
|
|
||||||
private static final String MISSING_DEVICE_CAPABILITIES_COUNTER_NAME =
|
|
||||||
MetricsUtil.name(DeviceController.class, "missingDeviceCapabilities");
|
|
||||||
|
|
||||||
public DeviceController(byte[] linkDeviceSecret,
|
public DeviceController(byte[] linkDeviceSecret,
|
||||||
AccountsManager accounts,
|
AccountsManager accounts,
|
||||||
MessagesManager messages,
|
MessagesManager messages,
|
||||||
|
@ -183,7 +176,7 @@ public class DeviceController {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated callers should use {@link #linkDevice(BasicAuthorizationHeader, String, LinkDeviceRequest, ContainerRequest)}
|
* @deprecated callers should use {@link #linkDevice(BasicAuthorizationHeader, LinkDeviceRequest, ContainerRequest)}
|
||||||
* instead
|
* instead
|
||||||
*/
|
*/
|
||||||
@PUT
|
@PUT
|
||||||
|
@ -194,7 +187,6 @@ public class DeviceController {
|
||||||
@Deprecated(forRemoval = true)
|
@Deprecated(forRemoval = true)
|
||||||
public DeviceResponse verifyDeviceToken(@PathParam("verification_code") String verificationCode,
|
public DeviceResponse verifyDeviceToken(@PathParam("verification_code") String verificationCode,
|
||||||
@HeaderParam(HttpHeaders.AUTHORIZATION) BasicAuthorizationHeader authorizationHeader,
|
@HeaderParam(HttpHeaders.AUTHORIZATION) BasicAuthorizationHeader authorizationHeader,
|
||||||
@HeaderParam(HttpHeaders.USER_AGENT) final String userAgent,
|
|
||||||
@NotNull @Valid AccountAttributes accountAttributes,
|
@NotNull @Valid AccountAttributes accountAttributes,
|
||||||
@Context ContainerRequest containerRequest)
|
@Context ContainerRequest containerRequest)
|
||||||
throws RateLimitExceededException, DeviceLimitExceededException {
|
throws RateLimitExceededException, DeviceLimitExceededException {
|
||||||
|
@ -203,8 +195,7 @@ public class DeviceController {
|
||||||
verificationCode,
|
verificationCode,
|
||||||
accountAttributes,
|
accountAttributes,
|
||||||
containerRequest,
|
containerRequest,
|
||||||
Optional.empty(),
|
Optional.empty());
|
||||||
userAgent);
|
|
||||||
|
|
||||||
final Account account = accountAndDevice.first();
|
final Account account = accountAndDevice.first();
|
||||||
final Device device = accountAndDevice.second();
|
final Device device = accountAndDevice.second();
|
||||||
|
@ -229,7 +220,6 @@ public class DeviceController {
|
||||||
name = "Retry-After",
|
name = "Retry-After",
|
||||||
description = "If present, an positive integer indicating the number of seconds before a subsequent attempt could succeed"))
|
description = "If present, an positive integer indicating the number of seconds before a subsequent attempt could succeed"))
|
||||||
public DeviceResponse linkDevice(@HeaderParam(HttpHeaders.AUTHORIZATION) BasicAuthorizationHeader authorizationHeader,
|
public DeviceResponse linkDevice(@HeaderParam(HttpHeaders.AUTHORIZATION) BasicAuthorizationHeader authorizationHeader,
|
||||||
@HeaderParam(HttpHeaders.USER_AGENT) final String userAgent,
|
|
||||||
@NotNull @Valid LinkDeviceRequest linkDeviceRequest,
|
@NotNull @Valid LinkDeviceRequest linkDeviceRequest,
|
||||||
@Context ContainerRequest containerRequest)
|
@Context ContainerRequest containerRequest)
|
||||||
throws RateLimitExceededException, DeviceLimitExceededException {
|
throws RateLimitExceededException, DeviceLimitExceededException {
|
||||||
|
@ -238,8 +228,7 @@ public class DeviceController {
|
||||||
linkDeviceRequest.verificationCode(),
|
linkDeviceRequest.verificationCode(),
|
||||||
linkDeviceRequest.accountAttributes(),
|
linkDeviceRequest.accountAttributes(),
|
||||||
containerRequest,
|
containerRequest,
|
||||||
Optional.of(linkDeviceRequest.deviceActivationRequest()),
|
Optional.of(linkDeviceRequest.deviceActivationRequest()));
|
||||||
userAgent);
|
|
||||||
|
|
||||||
final Account account = accountAndDevice.first();
|
final Account account = accountAndDevice.first();
|
||||||
final Device device = accountAndDevice.second();
|
final Device device = accountAndDevice.second();
|
||||||
|
@ -353,8 +342,7 @@ public class DeviceController {
|
||||||
final String verificationCode,
|
final String verificationCode,
|
||||||
final AccountAttributes accountAttributes,
|
final AccountAttributes accountAttributes,
|
||||||
final ContainerRequest containerRequest,
|
final ContainerRequest containerRequest,
|
||||||
final Optional<DeviceActivationRequest> maybeDeviceActivationRequest,
|
final Optional<DeviceActivationRequest> maybeDeviceActivationRequest)
|
||||||
final String userAgent)
|
|
||||||
throws RateLimitExceededException, DeviceLimitExceededException {
|
throws RateLimitExceededException, DeviceLimitExceededException {
|
||||||
|
|
||||||
final Optional<UUID> maybeAciFromToken = checkVerificationToken(verificationCode);
|
final Optional<UUID> maybeAciFromToken = checkVerificationToken(verificationCode);
|
||||||
|
@ -392,14 +380,6 @@ public class DeviceController {
|
||||||
}
|
}
|
||||||
|
|
||||||
final DeviceCapabilities capabilities = accountAttributes.getCapabilities();
|
final DeviceCapabilities capabilities = accountAttributes.getCapabilities();
|
||||||
|
|
||||||
if (capabilities == null) {
|
|
||||||
Metrics.counter(MISSING_DEVICE_CAPABILITIES_COUNTER_NAME,
|
|
||||||
Tags.of(UserAgentTagUtil.getPlatformTag(userAgent),
|
|
||||||
io.micrometer.core.instrument.Tag.of("atomic", String.valueOf(maybeDeviceActivationRequest.isPresent()))))
|
|
||||||
.increment();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (capabilities != null && isCapabilityDowngrade(account, capabilities)) {
|
if (capabilities != null && isCapabilityDowngrade(account, capabilities)) {
|
||||||
throw new WebApplicationException(Response.status(409).build());
|
throw new WebApplicationException(Response.status(409).build());
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,12 +58,10 @@ public class RegistrationController {
|
||||||
.register(Metrics.globalRegistry);
|
.register(Metrics.globalRegistry);
|
||||||
|
|
||||||
private static final String ACCOUNT_CREATED_COUNTER_NAME = name(RegistrationController.class, "accountCreated");
|
private static final String ACCOUNT_CREATED_COUNTER_NAME = name(RegistrationController.class, "accountCreated");
|
||||||
private static final String MISSING_DEVICE_CAPABILITIES_COUNTER_NAME =
|
|
||||||
name(RegistrationController.class, "missingDeviceCapabilities");
|
|
||||||
|
|
||||||
private static final String COUNTRY_CODE_TAG_NAME = "countryCode";
|
private static final String COUNTRY_CODE_TAG_NAME = "countryCode";
|
||||||
private static final String REGION_CODE_TAG_NAME = "regionCode";
|
private static final String REGION_CODE_TAG_NAME = "regionCode";
|
||||||
private static final String VERIFICATION_TYPE_TAG_NAME = "verification";
|
private static final String VERIFICATION_TYPE_TAG_NAME = "verification";
|
||||||
|
private static final String INVALID_ACCOUNT_ATTRS_COUNTER_NAME = name(RegistrationController.class, "invalidAccountAttrs");
|
||||||
|
|
||||||
private final AccountsManager accounts;
|
private final AccountsManager accounts;
|
||||||
private final PhoneVerificationTokenManager phoneVerificationTokenManager;
|
private final PhoneVerificationTokenManager phoneVerificationTokenManager;
|
||||||
|
@ -109,12 +107,6 @@ public class RegistrationController {
|
||||||
final String number = authorizationHeader.getUsername();
|
final String number = authorizationHeader.getUsername();
|
||||||
final String password = authorizationHeader.getPassword();
|
final String password = authorizationHeader.getPassword();
|
||||||
|
|
||||||
if (registrationRequest.accountAttributes().getCapabilities() == null) {
|
|
||||||
Metrics.counter(MISSING_DEVICE_CAPABILITIES_COUNTER_NAME,
|
|
||||||
Tags.of(UserAgentTagUtil.getPlatformTag(userAgent)))
|
|
||||||
.increment();
|
|
||||||
}
|
|
||||||
|
|
||||||
RateLimiter.adaptLegacyException(() -> rateLimiters.getRegistrationLimiter().validate(number));
|
RateLimiter.adaptLegacyException(() -> rateLimiters.getRegistrationLimiter().validate(number));
|
||||||
|
|
||||||
final PhoneVerificationRequest.VerificationType verificationType = phoneVerificationTokenManager.verify(number,
|
final PhoneVerificationRequest.VerificationType verificationType = phoneVerificationTokenManager.verify(number,
|
||||||
|
|
Loading…
Reference in New Issue