mirror of
https://github.com/signalapp/Signal-Server
synced 2026-04-22 03:48:04 +01:00
Derive username from ACI for CDS{H,I} (#989)
* Derive username from ACI for CDS{H,I}
* Update sample YAML.
This commit is contained in:
@@ -34,16 +34,8 @@ public class DirectoryV2Controller {
|
||||
@Path("/auth")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public Response getAuthToken(@Auth AuthenticatedAccount auth) {
|
||||
|
||||
final UUID uuid = auth.getAccount().getUuid();
|
||||
final String e164 = auth.getAccount().getNumber();
|
||||
final long e164AsLong = Long.parseLong(e164, e164.indexOf('+'), e164.length() - 1, 10);
|
||||
|
||||
final byte[] uuidAndNumber = ByteUtil.combine(UUIDUtil.toBytes(uuid), Util.longToByteArray(e164AsLong));
|
||||
final String username = Base64.getEncoder().encodeToString(uuidAndNumber);
|
||||
|
||||
final ExternalServiceCredentials credentials = directoryServiceTokenGenerator.generateFor(username);
|
||||
|
||||
final ExternalServiceCredentials credentials = directoryServiceTokenGenerator.generateFor(uuid.toString());
|
||||
return Response.ok().entity(credentials).build();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user