mirror of
https://github.com/signalapp/Signal-Server
synced 2026-04-22 00:08:07 +01:00
Enforce no capability downgrade on device verification
This commit is contained in:
committed by
Jon Chambers
parent
e7572094b5
commit
2c6b646d87
@@ -190,6 +190,11 @@ public class DeviceController {
|
||||
throw new DeviceLimitExceededException(account.get().getDevices().size(), MAX_DEVICES);
|
||||
}
|
||||
|
||||
final DeviceCapabilities capabilities = accountAttributes.getCapabilities();
|
||||
if (capabilities != null && isCapabilityDowngrade(account.get(), capabilities)) {
|
||||
throw new WebApplicationException(Response.status(409).build());
|
||||
}
|
||||
|
||||
Device device = new Device();
|
||||
device.setName(accountAttributes.getName());
|
||||
device.setAuthenticationCredentials(new AuthenticationCredentials(password));
|
||||
@@ -235,4 +240,9 @@ public class DeviceController {
|
||||
int randomInt = 100000 + random.nextInt(900000);
|
||||
return new VerificationCode(randomInt);
|
||||
}
|
||||
|
||||
private boolean isCapabilityDowngrade(Account account, DeviceCapabilities capabilities) {
|
||||
return (!capabilities.isGv2() && account.isGroupsV2Supported())
|
||||
|| (!capabilities.isUuid() && account.isUuidAddressingSupported());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user