-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2a99529
commit a01fcda
Showing
5 changed files
with
75 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
...ava/org/whispersystems/textsecuregcm/configuration/SecureValueRecovery2Configuration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/* | ||
* Copyright 2013-2020 Signal Messenger, LLC | ||
* SPDX-License-Identifier: AGPL-3.0-only | ||
*/ | ||
package org.whispersystems.textsecuregcm.configuration; | ||
|
||
import org.whispersystems.textsecuregcm.util.ExactlySize; | ||
|
||
public record SecureValueRecovery2Configuration( | ||
@ExactlySize({32}) byte[] userAuthenticationTokenSharedSecret, | ||
@ExactlySize({32}) byte[] userIdTokenSharedSecret) { | ||
} |
44 changes: 44 additions & 0 deletions
44
...ain/java/org/whispersystems/textsecuregcm/controllers/SecureValueRecovery2Controller.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright 2013-2021 Signal Messenger, LLC | ||
* SPDX-License-Identifier: AGPL-3.0-only | ||
*/ | ||
|
||
package org.whispersystems.textsecuregcm.controllers; | ||
|
||
import com.codahale.metrics.annotation.Timed; | ||
import io.dropwizard.auth.Auth; | ||
import javax.ws.rs.GET; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.Produces; | ||
import javax.ws.rs.core.MediaType; | ||
import org.apache.commons.codec.DecoderException; | ||
import org.whispersystems.textsecuregcm.auth.AuthenticatedAccount; | ||
import org.whispersystems.textsecuregcm.auth.ExternalServiceCredentials; | ||
import org.whispersystems.textsecuregcm.auth.ExternalServiceCredentialsGenerator; | ||
import org.whispersystems.textsecuregcm.configuration.SecureValueRecovery2Configuration; | ||
|
||
@Path("/v2/backup") | ||
public class SecureValueRecovery2Controller { | ||
|
||
public static ExternalServiceCredentialsGenerator credentialsGenerator(final SecureValueRecovery2Configuration cfg) | ||
throws DecoderException { | ||
return ExternalServiceCredentialsGenerator | ||
.builder(cfg.userAuthenticationTokenSharedSecret()) | ||
.withUserDerivationKey(cfg.userIdTokenSharedSecret()) | ||
.build(); | ||
} | ||
|
||
private final ExternalServiceCredentialsGenerator backupServiceCredentialGenerator; | ||
|
||
public SecureValueRecovery2Controller(ExternalServiceCredentialsGenerator backupServiceCredentialGenerator) { | ||
this.backupServiceCredentialGenerator = backupServiceCredentialGenerator; | ||
} | ||
|
||
@Timed | ||
@GET | ||
@Path("/auth") | ||
@Produces(MediaType.APPLICATION_JSON) | ||
public ExternalServiceCredentials getAuth(@Auth AuthenticatedAccount auth) { | ||
return backupServiceCredentialGenerator.generateFor(auth.getAccount().getUuid().toString()); | ||
} | ||
} |