From 578f96f426684b98a5fa4815e38733b3e36ee12a Mon Sep 17 00:00:00 2001 From: Chris Eager Date: Thu, 15 Oct 2026 14:04:31 -0400 Subject: [PATCH] Add `@ManagedAsync` to controller methods that block --- .../controllers/AccountController.java | 17 +++++++++++++++++ .../controllers/AccountControllerV2.java | 4 ++++ .../controllers/AttachmentControllerV4.java | 2 ++ .../controllers/CallLinkController.java | 2 ++ .../controllers/CertificateController.java | 3 +++ .../controllers/ChallengeController.java | 3 +++ .../controllers/DeviceController.java | 6 ++++++ .../controllers/DonationController.java | 1 + .../controllers/MessageController.java | 2 ++ .../controllers/ProfileController.java | 2 ++ .../controllers/ProvisioningController.java | 2 ++ .../controllers/RegistrationController.java | 2 ++ .../controllers/RemoteConfigController.java | 2 ++ .../SecureValueRecovery2Controller.java | 2 ++ .../controllers/StickerController.java | 2 ++ .../controllers/VerificationController.java | 6 ++++++ 16 files changed, 58 insertions(+) diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/AccountController.java b/service/src/main/java/org/whispersystems/textsecuregcm/controllers/AccountController.java index 065cd30b4..17a6c1987 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/AccountController.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/controllers/AccountController.java @@ -38,6 +38,7 @@ import java.util.UUID; import java.util.concurrent.CompletableFuture; import javax.annotation.Nullable; import org.apache.commons.lang3.StringUtils; +import org.glassfish.jersey.server.ManagedAsync; import org.signal.libsignal.usernames.BaseUsernameException; import org.whispersystems.textsecuregcm.auth.AuthenticatedDevice; import org.whispersystems.textsecuregcm.auth.SaltedTokenHash; @@ -97,6 +98,7 @@ public class AccountController { @Path("/gcm/") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) + @ManagedAsync public void setGcmRegistrationId(@Auth AuthenticatedDevice auth, @NotNull @Valid GcmRegistrationId registrationId) { @@ -118,6 +120,7 @@ public class AccountController { @DELETE @Path("/gcm/") + @ManagedAsync public void deleteGcmRegistrationId(@Auth AuthenticatedDevice auth) { accounts.updateDevice(auth.accountIdentifier(), auth.deviceId(), d -> { d.setGcmId(null); @@ -130,6 +133,7 @@ public class AccountController { @Path("/apn/") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) + @ManagedAsync public void setApnRegistrationId(@Auth AuthenticatedDevice auth, @NotNull @Valid ApnRegistrationId registrationId) { @@ -144,6 +148,7 @@ public class AccountController { @DELETE @Path("/apn/") + @ManagedAsync public void deleteApnRegistrationId(@Auth AuthenticatedDevice auth) { accounts.updateDevice(auth.accountIdentifier(), auth.deviceId(), d -> { d.setApnId(null); @@ -155,6 +160,7 @@ public class AccountController { @PUT @Produces(MediaType.APPLICATION_JSON) @Path("/registration_lock") + @ManagedAsync public void setRegistrationLock(@Auth AuthenticatedDevice auth, @NotNull @Valid RegistrationLock accountLock) { final SaltedTokenHash credentials = SaltedTokenHash.generateFor(accountLock.registrationLock()); @@ -168,6 +174,7 @@ public class AccountController { @DELETE @Path("/registration_lock") + @ManagedAsync public void removeRegistrationLock(@Auth AuthenticatedDevice auth) { accounts.update(auth.accountIdentifier(), a -> a.setRegistrationLock(null, null)); } @@ -183,6 +190,7 @@ public class AccountController { @ApiResponse(responseCode = "204", description = "Device name changed successfully") @ApiResponse(responseCode = "404", description = "No device found with the given ID") @ApiResponse(responseCode = "403", description = "Not authorized to change the name of the device with the given ID") + @ManagedAsync public void setName(@Auth final AuthenticatedDevice auth, @NotNull @Valid final DeviceName deviceName, @@ -214,6 +222,7 @@ public class AccountController { @Path("/attributes/") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) + @ManagedAsync public void setAccountAttributes( @Auth AuthenticatedDevice auth, @HeaderParam(HeaderUtils.X_SIGNAL_AGENT) String signalAgent, @@ -260,6 +269,7 @@ public class AccountController { @GET @Path("/whoami") @Produces(MediaType.APPLICATION_JSON) + @ManagedAsync public AccountIdentityResponse whoAmI(@Auth final AuthenticatedDevice auth) { final Account account = accounts.getByAccountIdentifier(auth.accountIdentifier()) .orElseThrow(() -> new WebApplicationException(Status.UNAUTHORIZED)); @@ -278,6 +288,7 @@ public class AccountController { ) @ApiResponse(responseCode = "204", description = "Username successfully deleted.", useReturnTypeSchema = true) @ApiResponse(responseCode = "401", description = "Account authentication check failed.") + @ManagedAsync public void deleteUsernameHash(@Auth final AuthenticatedDevice auth) { accounts.clearUsernameHash(auth.accountIdentifier()); } @@ -298,6 +309,7 @@ public class AccountController { @ApiResponse(responseCode = "409", description = "All username hashes from the list are taken.") @ApiResponse(responseCode = "422", description = "Invalid request format.") @ApiResponse(responseCode = "429", description = "Ratelimited.") + @ManagedAsync public ReserveUsernameHashResponse reserveUsernameHash( @Auth final AuthenticatedDevice auth, @NotNull @Valid final ReserveUsernameHashRequest usernameRequest) throws RateLimitExceededException { @@ -337,6 +349,7 @@ public class AccountController { @ApiResponse(responseCode = "410", description = "Username hash not available (username can't be used).") @ApiResponse(responseCode = "422", description = "Invalid request format.") @ApiResponse(responseCode = "429", description = "Ratelimited.") + @ManagedAsync public UsernameHashResponse confirmUsernameHash( @Auth final AuthenticatedDevice auth, @NotNull @Valid final ConfirmUsernameHashRequest confirmRequest) throws RateLimitExceededException { @@ -417,6 +430,7 @@ public class AccountController { @ApiResponse(responseCode = "409", description = "Username is not set for the account.") @ApiResponse(responseCode = "422", description = "Invalid request format.") @ApiResponse(responseCode = "429", description = "Ratelimited.") + @ManagedAsync public UsernameLinkHandle updateUsernameLink( @Auth final AuthenticatedDevice auth, @NotNull @Valid final EncryptedUsername encryptedUsername) throws RateLimitExceededException { @@ -454,6 +468,7 @@ public class AccountController { @ApiResponse(responseCode = "204", description = "Username Link successfully deleted.", useReturnTypeSchema = true) @ApiResponse(responseCode = "401", description = "Account authentication check failed.") @ApiResponse(responseCode = "429", description = "Ratelimited.") + @ManagedAsync public void deleteUsernameLink(@Auth final AuthenticatedDevice auth) throws RateLimitExceededException { // check ratelimiter for username link operations rateLimiters.forDescriptor(RateLimiters.For.USERNAME_LINK_OPERATION).validate(auth.accountIdentifier()); @@ -503,6 +518,7 @@ public class AccountController { @HEAD @Path("/account/{identifier}") @RateLimitedByIp(RateLimiters.For.CHECK_ACCOUNT_EXISTENCE) + @ManagedAsync public Response accountExists( @Auth final Optional authenticatedAccount, @@ -519,6 +535,7 @@ public class AccountController { @DELETE @Path("/me") + @ManagedAsync public void deleteAccount(@Auth AuthenticatedDevice auth) { accounts.delete(auth.accountIdentifier(), AccountsManager.DeletionReason.USER_REQUEST); } diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/AccountControllerV2.java b/service/src/main/java/org/whispersystems/textsecuregcm/controllers/AccountControllerV2.java index d96737a0c..010f65c33 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/AccountControllerV2.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/controllers/AccountControllerV2.java @@ -33,6 +33,7 @@ import java.io.IOException; import java.time.Instant; import java.util.UUID; import org.apache.commons.lang3.StringUtils; +import org.glassfish.jersey.server.ManagedAsync; import org.whispersystems.textsecuregcm.auth.AuthenticatedDevice; import org.whispersystems.textsecuregcm.auth.ChangesPhoneNumber; import org.whispersystems.textsecuregcm.auth.InvalidRegistrationSessionException; @@ -84,6 +85,7 @@ public class AccountControllerV2 { @ApiResponse(responseCode = "429", description = "Too many attempts", headers = @Header( name = "Retry-After", description = "If present, a positive integer indicating the number of seconds before a subsequent attempt could succeed")) + @ManagedAsync public AccountIdentityResponse changeNumber(@Auth final AuthenticatedDevice authenticatedDevice, @NotNull @Valid final ChangeNumberRequest request, @HeaderParam(HttpHeaders.USER_AGENT) final String userAgentString, @@ -151,6 +153,7 @@ public class AccountControllerV2 { @Produces(MediaType.APPLICATION_JSON) @Operation(summary = "Sets whether the account should be discoverable by phone number in the directory.") @ApiResponse(responseCode = "204", description = "The setting was successfully updated.") + @ManagedAsync public void setPhoneNumberDiscoverability( @Auth AuthenticatedDevice auth, @NotNull @Valid PhoneNumberDiscoverabilityRequest phoneNumberDiscoverability) { @@ -171,6 +174,7 @@ public class AccountControllerV2 { @ApiResponse(responseCode = "200", description = "Response with data report. A plain text representation is a field in the response.", useReturnTypeSchema = true) + @ManagedAsync public AccountDataReportResponse getAccountDataReport(@Auth final AuthenticatedDevice auth) { final Account account = accountsManager.getByAccountIdentifier(auth.accountIdentifier()) diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/AttachmentControllerV4.java b/service/src/main/java/org/whispersystems/textsecuregcm/controllers/AttachmentControllerV4.java index c20234c7b..bf314a212 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/AttachmentControllerV4.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/controllers/AttachmentControllerV4.java @@ -30,6 +30,7 @@ import java.util.Map; import java.util.Optional; import javax.annotation.Nonnull; import javax.annotation.Nullable; +import org.glassfish.jersey.server.ManagedAsync; import org.whispersystems.textsecuregcm.attachments.AttachmentGenerator; import org.whispersystems.textsecuregcm.attachments.AttachmentUtil; import org.whispersystems.textsecuregcm.attachments.GcsAttachmentGenerator; @@ -99,6 +100,7 @@ public class AttachmentControllerV4 { @ApiResponse(responseCode = "429", description = "Too many attempts", headers = @Header( name = "Retry-After", description = "If present, an positive integer indicating the number of seconds before a subsequent attempt could succeed")) + @ManagedAsync public AttachmentDescriptorV3 getAttachmentUploadForm( @Auth AuthenticatedDevice auth, @Parameter(description = "The size of the attachment to upload in bytes") diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/CallLinkController.java b/service/src/main/java/org/whispersystems/textsecuregcm/controllers/CallLinkController.java index 84e7d51a9..92459cb1a 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/CallLinkController.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/controllers/CallLinkController.java @@ -14,6 +14,7 @@ import jakarta.ws.rs.QueryParam; import jakarta.ws.rs.core.MediaType; import java.time.Instant; import java.time.temporal.ChronoUnit; +import org.glassfish.jersey.server.ManagedAsync; import org.signal.libsignal.protocol.ServiceId; import org.signal.libsignal.zkgroup.GenericServerSecretParams; import org.signal.libsignal.zkgroup.InvalidInputException; @@ -55,6 +56,7 @@ public class CallLinkController { @ApiResponse(responseCode = "401", description = "Account authentication check failed.") @ApiResponse(responseCode = "422", description = "Invalid request format.") @ApiResponse(responseCode = "429", description = "Ratelimited.") + @ManagedAsync public CreateCallLinkCredential getCreateAuth( final @Auth AuthenticatedDevice auth, final @NotNull @Valid GetCreateCallLinkCredentialsRequest request, diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/CertificateController.java b/service/src/main/java/org/whispersystems/textsecuregcm/controllers/CertificateController.java index 5279c7158..97bcb6740 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/CertificateController.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/controllers/CertificateController.java @@ -29,6 +29,7 @@ import java.util.List; import java.util.Objects; import java.util.Optional; import javax.annotation.Nonnull; +import org.glassfish.jersey.server.ManagedAsync; import org.signal.libsignal.protocol.ServiceId; import org.signal.libsignal.zkgroup.GenericServerSecretParams; import org.signal.libsignal.zkgroup.auth.AuthCredentialWithPniResponse; @@ -77,6 +78,7 @@ public class CertificateController { @GET @Produces(MediaType.APPLICATION_JSON) @Path("/delivery") + @ManagedAsync public DeliveryCertificate getDeliveryCertificate(@Auth AuthenticatedDevice auth, @QueryParam("includeE164") @DefaultValue("true") boolean includeE164) { @@ -96,6 +98,7 @@ public class CertificateController { @GET @Produces(MediaType.APPLICATION_JSON) @Path("/auth/group") + @ManagedAsync public GroupCredentials getGroupAuthenticationCredentials( @Auth AuthenticatedDevice auth, @QueryParam("redemptionStartSeconds") long startSeconds, diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/ChallengeController.java b/service/src/main/java/org/whispersystems/textsecuregcm/controllers/ChallengeController.java index 84f44d7a1..caf5881f2 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/ChallengeController.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/controllers/ChallengeController.java @@ -31,6 +31,7 @@ import jakarta.ws.rs.core.Context; import jakarta.ws.rs.core.MediaType; import jakarta.ws.rs.core.Response; import java.io.IOException; +import org.glassfish.jersey.server.ManagedAsync; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.whispersystems.textsecuregcm.auth.AuthenticatedDevice; @@ -88,6 +89,7 @@ public class ChallengeController { @ApiResponse(responseCode = "429", description = "Too many attempts", headers = @Header( name = "Retry-After", description = "If present, an positive integer indicating the number of seconds before a subsequent attempt could succeed")) + @ManagedAsync public Response handleChallengeResponse(@Auth final AuthenticatedDevice auth, @Valid final AnswerChallengeRequest answerRequest, @Context final ContainerRequestContext requestContext, @@ -182,6 +184,7 @@ public class ChallengeController { @ApiResponse(responseCode = "429", description = "Too many attempts", headers = @Header( name = "Retry-After", description = "If present, an positive integer indicating the number of seconds before a subsequent attempt could succeed")) + @ManagedAsync public Response requestPushChallenge(@Auth final AuthenticatedDevice auth, @Context ContainerRequestContext requestContext) { diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/DeviceController.java b/service/src/main/java/org/whispersystems/textsecuregcm/controllers/DeviceController.java index 8a3488956..4627bd2f8 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/DeviceController.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/controllers/DeviceController.java @@ -47,6 +47,7 @@ import java.util.concurrent.CompletionStage; import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; import javax.annotation.Nullable; +import org.glassfish.jersey.server.ManagedAsync; import org.whispersystems.textsecuregcm.auth.AuthenticatedDevice; import org.whispersystems.textsecuregcm.auth.BasicAuthorizationHeader; import org.whispersystems.textsecuregcm.auth.ChangesLinkedDevices; @@ -135,6 +136,7 @@ public class DeviceController { @GET @Produces(MediaType.APPLICATION_JSON) + @ManagedAsync public DeviceInfoList getDevices(@Auth AuthenticatedDevice auth) { // Devices may change their own names (and primary devices may change the names of linked devices) and so the device // state associated with the authenticated account may be stale. Fetch a fresh copy to compensate. @@ -149,6 +151,7 @@ public class DeviceController { @Produces(MediaType.APPLICATION_JSON) @Path("/{device_id}") @ChangesLinkedDevices + @ManagedAsync public void removeDevice(@Auth AuthenticatedDevice auth, @PathParam("device_id") byte deviceId) { if (auth.deviceId() != Device.PRIMARY_ID && auth.deviceId() != deviceId) { throw new WebApplicationException(Response.Status.UNAUTHORIZED); @@ -189,6 +192,7 @@ public class DeviceController { @ApiResponse(responseCode = "429", description = "Too many attempts", headers = @Header( name = "Retry-After", description = "If present, an positive integer indicating the number of seconds before a subsequent attempt could succeed")) + @ManagedAsync public LinkDeviceToken createDeviceToken(@Auth AuthenticatedDevice auth) throws RateLimitExceededException, DeviceLimitExceededException { @@ -223,6 +227,7 @@ public class DeviceController { @ApiResponse(responseCode = "429", description = "Too many attempts", headers = @Header( name = "Retry-After", description = "If present, an positive integer indicating the number of seconds before a subsequent attempt could succeed")) + @ManagedAsync public LinkDeviceResponse linkDevice(@HeaderParam(HttpHeaders.AUTHORIZATION) @NotNull BasicAuthorizationHeader authorizationHeader, @HeaderParam(HttpHeaders.USER_AGENT) @Nullable String userAgent, @NotNull @Valid LinkDeviceRequest linkDeviceRequest) @@ -391,6 +396,7 @@ public class DeviceController { @PUT @Produces(MediaType.APPLICATION_JSON) @Path("/capabilities") + @ManagedAsync public void setCapabilities(@Auth final AuthenticatedDevice auth, @NotNull final Map capabilities) { accounts.updateDevice(auth.accountIdentifier(), auth.deviceId(), d -> d.setCapabilities(DeviceCapabilityAdapter.mapToSet(capabilities))); diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/DonationController.java b/service/src/main/java/org/whispersystems/textsecuregcm/controllers/DonationController.java index 8433beb39..939e26934 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/DonationController.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/controllers/DonationController.java @@ -160,6 +160,7 @@ public class DonationController { @ApiResponse(responseCode = "401", description = "Account authentication check failed") @ApiResponse(responseCode = "422", description = "Invalid request format") @ApiResponse(responseCode = "429", description = "Rate-limited; reduce requested permit count and/or try again after the prescribed delay") + @ManagedAsync public CreateDonationPermitResponse createPermits(@Auth final AuthenticatedDevice auth, @NotNull @Valid final CreateDonationPermitsRequest request) throws RateLimitExceededException { diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/MessageController.java b/service/src/main/java/org/whispersystems/textsecuregcm/controllers/MessageController.java index d12c1d3f2..ffc6c08be 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/MessageController.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/controllers/MessageController.java @@ -463,6 +463,7 @@ public class MessageController { @ApiResponse( responseCode = "410", description = "Mismatched registration ids supplied for some recipient devices", content = @Content(schema = @Schema(implementation = AccountStaleDevices[].class))) + @ManagedAsync public Response sendMultiRecipientMessage( @Deprecated @Parameter(description="The bitwise xor of the unidentified access keys for every recipient of the message. Will be replaced with group send endorsements") @@ -729,6 +730,7 @@ public class MessageController { @POST @Consumes(MediaType.APPLICATION_JSON) @Path("/report/{source}/{messageGuid}") + @ManagedAsync public Response reportSpamMessage( @Auth AuthenticatedDevice auth, @PathParam("source") UUID source, diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/ProfileController.java b/service/src/main/java/org/whispersystems/textsecuregcm/controllers/ProfileController.java index 816d1d8ae..869d6b843 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/ProfileController.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/controllers/ProfileController.java @@ -170,6 +170,7 @@ public class ProfileController { @ApiResponse(responseCode = "403", description = "The request contained a payment address, but payments are not supported in the region of the account’s phone number or the caller's ASN if the account does not have a phone number.") @ApiResponse(responseCode = "412", description = "The requesting account has the profiles_v2 capability") @ApiResponse(responseCode = "422", description = "Invalid request format") + @ManagedAsync public Response setProfile(@Auth AuthenticatedDevice auth, @NotNull @Valid CreateProfileRequest request, @Context final ContainerRequestContext requestContext) { @@ -278,6 +279,7 @@ public class ProfileController { @ApiResponse(responseCode = "401", description = "Not authorized to access this profile.") @ApiResponse(responseCode = "404", description = "Profile or account not found.") @ApiResponse(responseCode = "429", description = "Rate limit exceeded.") + @ManagedAsync public ExpiringProfileKeyCredentialProfileResponse getProfile( @Auth Optional maybeAuthenticatedDevice, @HeaderParam(HeaderUtils.UNIDENTIFIED_ACCESS_KEY) Optional accessKey, diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/ProvisioningController.java b/service/src/main/java/org/whispersystems/textsecuregcm/controllers/ProvisioningController.java index 7ff684c17..2148be4c0 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/ProvisioningController.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/controllers/ProvisioningController.java @@ -29,6 +29,7 @@ import jakarta.ws.rs.WebApplicationException; import jakarta.ws.rs.core.MediaType; import jakarta.ws.rs.core.Response; import java.util.Base64; +import org.glassfish.jersey.server.ManagedAsync; import org.whispersystems.textsecuregcm.auth.AuthenticatedDevice; import org.whispersystems.textsecuregcm.entities.ProvisioningMessage; import org.whispersystems.textsecuregcm.limits.RateLimiters; @@ -76,6 +77,7 @@ public class ProvisioningController { @ApiResponse(responseCode="204", description="The provisioning message was delivered to the given provisioning address") @ApiResponse(responseCode="400", description="The provisioning message was too large") @ApiResponse(responseCode="404", description="No device with the given provisioning address was connected at the time of the request") + @ManagedAsync public void sendProvisioningMessage(@Auth final AuthenticatedDevice auth, @Parameter(description = "The temporary provisioning address to which to send a provisioning message") diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/RegistrationController.java b/service/src/main/java/org/whispersystems/textsecuregcm/controllers/RegistrationController.java index 683c62008..0ccdb6ef1 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/RegistrationController.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/controllers/RegistrationController.java @@ -45,6 +45,7 @@ import java.util.UUID; import javax.annotation.Nullable; import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.StringUtils; +import org.glassfish.jersey.server.ManagedAsync; import org.signal.libsignal.zkgroup.InvalidInputException; import org.signal.libsignal.zkgroup.VerificationFailedException; import org.signal.libsignal.zkgroup.receipts.ReceiptCredentialPresentation; @@ -161,6 +162,7 @@ public class RegistrationController { """, content = @Content(schema = @Schema(implementation = MfaFailureExceptionMapper.MfaFailureResponse.class))) @ApiResponse(responseCode = "499", description = "Client must support post-quantum ratchet") + @ManagedAsync public AccountCreationResponse register( @Parameter( in = ParameterIn.HEADER, diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/RemoteConfigController.java b/service/src/main/java/org/whispersystems/textsecuregcm/controllers/RemoteConfigController.java index 211cfd0ea..37dc94a8e 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/RemoteConfigController.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/controllers/RemoteConfigController.java @@ -24,6 +24,7 @@ import jakarta.ws.rs.core.Response; import java.util.HexFormat; import java.util.Map; import javax.annotation.Nullable; +import org.glassfish.jersey.server.ManagedAsync; import org.whispersystems.textsecuregcm.auth.AuthenticatedDevice; import org.whispersystems.textsecuregcm.entities.RemoteConfigurationResponse; import org.whispersystems.textsecuregcm.storage.RemoteConfigsManager; @@ -52,6 +53,7 @@ public class RemoteConfigController { @ApiResponse(responseCode = "304", description = "There is no change since the last fetch", content = {}) @ApiResponse(responseCode = "401", description = "This request requires authentication", content = {}) + @ManagedAsync public Response getAll( @Auth AuthenticatedDevice auth, diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/SecureValueRecovery2Controller.java b/service/src/main/java/org/whispersystems/textsecuregcm/controllers/SecureValueRecovery2Controller.java index 99a390712..15fd60b08 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/SecureValueRecovery2Controller.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/controllers/SecureValueRecovery2Controller.java @@ -32,6 +32,7 @@ import java.util.HashSet; import java.util.List; import java.util.Optional; import java.util.stream.Collectors; +import org.glassfish.jersey.server.ManagedAsync; import org.whispersystems.textsecuregcm.auth.AuthenticatedDevice; import org.whispersystems.textsecuregcm.auth.ExternalServiceCredentials; import org.whispersystems.textsecuregcm.auth.ExternalServiceCredentialsGenerator; @@ -115,6 +116,7 @@ public class SecureValueRecovery2Controller { @ApiResponse(responseCode = "200", description = "`JSON` with the check results.", useReturnTypeSchema = true) @ApiResponse(responseCode = "422", description = "Provided list of SVR2 credentials could not be parsed") @ApiResponse(responseCode = "400", description = "`POST` request body is not a valid `JSON`") + @ManagedAsync public AuthCheckResponseV2 authCheck( @HeaderParam(HttpHeaders.USER_AGENT) final String userAgent, @NotNull @Valid final AuthCheckRequest request) { diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/StickerController.java b/service/src/main/java/org/whispersystems/textsecuregcm/controllers/StickerController.java index 835566abe..353affe96 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/StickerController.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/controllers/StickerController.java @@ -21,6 +21,7 @@ import java.time.Instant; import java.util.HexFormat; import java.util.LinkedList; import java.util.List; +import org.glassfish.jersey.server.ManagedAsync; import org.whispersystems.textsecuregcm.auth.AuthenticatedDevice; import org.whispersystems.textsecuregcm.entities.StickerPackFormUploadAttributes; import org.whispersystems.textsecuregcm.entities.StickerPackFormUploadAttributes.StickerPackFormUploadItem; @@ -49,6 +50,7 @@ public class StickerController { @GET @Produces(MediaType.APPLICATION_JSON) @Path("/pack/form/{count}") + @ManagedAsync public StickerPackFormUploadAttributes getStickersForm(@Auth AuthenticatedDevice auth, @PathParam("count") @Min(1) @Max(201) int stickerCount) throws RateLimitExceededException { diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/VerificationController.java b/service/src/main/java/org/whispersystems/textsecuregcm/controllers/VerificationController.java index d937ed55a..58d92fdd4 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/VerificationController.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/controllers/VerificationController.java @@ -60,6 +60,7 @@ import java.util.Objects; import java.util.Optional; import org.apache.commons.lang3.Strings; import org.apache.http.HttpStatus; +import org.glassfish.jersey.server.ManagedAsync; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.whispersystems.textsecuregcm.captcha.AssessmentResult; @@ -184,6 +185,7 @@ public class VerificationController { name = "Retry-After", description = "If present, an positive integer indicating the number of seconds before a subsequent attempt could succeed", schema = @Schema(implementation = Integer.class))) + @ManagedAsync public VerificationSessionResponse createSession(@NotNull @Valid final CreateVerificationSessionRequest request, @Context final ContainerRequestContext requestContext) throws RateLimitExceededException, ObsoletePhoneNumberFormatException { @@ -263,6 +265,7 @@ public class VerificationController { name = "Retry-After", description = "If present, an positive integer indicating the number of seconds before a subsequent attempt could succeed", schema = @Schema(implementation = Integer.class))) + @ManagedAsync public VerificationSessionResponse updateSession( @PathParam("sessionId") final String encodedSessionId, @HeaderParam(HttpHeaders.USER_AGENT) final String userAgent, @@ -518,6 +521,7 @@ public class VerificationController { @ApiResponse(responseCode = "400", description = "Invalid session ID") @ApiResponse(responseCode = "404", description = "Session with the specified ID could not be found") @ApiResponse(responseCode = "422", description = "Malformed session ID encoding") + @ManagedAsync public VerificationSessionResponse getSession(@PathParam("sessionId") final String encodedSessionId) { final RegistrationServiceSession registrationServiceSession = retrieveRegistrationServiceSession(encodedSessionId); @@ -564,6 +568,7 @@ public class VerificationController { future attempts to request or submit verification codes (since those attempts would be all but guaranteed to fail). """, content = @Content(schema = @Schema(implementation = RegistrationServiceSenderExceptionMapper.SendVerificationCodeFailureResponse.class))) + @ManagedAsync public VerificationSessionResponse requestVerificationCode(@PathParam("sessionId") final String encodedSessionId, @HeaderParam(HttpHeaders.USER_AGENT) final String userAgent, @Parameter(in = ParameterIn.HEADER, description = "Ordered list of languages in which the client prefers to receive SMS or voice verification messages") @HeaderParam(HttpHeaders.ACCEPT_LANGUAGE) @@ -700,6 +705,7 @@ public class VerificationController { name = "Retry-After", description = "If present, an positive integer indicating the number of seconds before a subsequent attempt could succeed", schema = @Schema(implementation = Integer.class))) + @ManagedAsync public VerificationSessionResponse verifyCode(@PathParam("sessionId") final String encodedSessionId, @HeaderParam(HttpHeaders.USER_AGENT) final String userAgent, @NotNull @Valid final SubmitVerificationCodeRequest submitVerificationCodeRequest) {