mirror of
https://github.com/google/nomulus.git
synced 2025-05-10 16:58:21 +02:00
Include the registry lock email in the JS object as a sensitive field (#658)
* Include the registry lock email in the JS object as a sensitive field * Change wording of exceptions to be more consistent
This commit is contained in:
parent
e20eb17458
commit
74d0cdce5b
6 changed files with 85 additions and 17 deletions
|
@ -454,7 +454,13 @@ public class RegistrarSettingsAction implements Runnable, JsonActionRunner.JsonA
|
||||||
.orElseThrow(
|
.orElseThrow(
|
||||||
() ->
|
() ->
|
||||||
new FormException(
|
new FormException(
|
||||||
"Not allowed to set registry lock password directly on new contact"));
|
"Cannot set registry lock password directly on new contact"));
|
||||||
|
// Can't modify registry lock email address
|
||||||
|
if (!Objects.equals(
|
||||||
|
updatedContact.getRegistryLockEmailAddress(),
|
||||||
|
existingContact.getRegistryLockEmailAddress())) {
|
||||||
|
throw new FormException("Cannot modify registryLockEmailAddress through the UI");
|
||||||
|
}
|
||||||
if (updatedContact.isRegistryLockAllowed()) {
|
if (updatedContact.isRegistryLockAllowed()) {
|
||||||
// the password must have been set before or the user was allowed to set it now
|
// the password must have been set before or the user was allowed to set it now
|
||||||
if (!existingContact.isAllowedToSetRegistryLockPassword()
|
if (!existingContact.isAllowedToSetRegistryLockPassword()
|
||||||
|
@ -464,7 +470,8 @@ public class RegistrarSettingsAction implements Runnable, JsonActionRunner.JsonA
|
||||||
}
|
}
|
||||||
if (updatedContact.isAllowedToSetRegistryLockPassword()) {
|
if (updatedContact.isAllowedToSetRegistryLockPassword()) {
|
||||||
if (!existingContact.isAllowedToSetRegistryLockPassword()) {
|
if (!existingContact.isAllowedToSetRegistryLockPassword()) {
|
||||||
throw new FormException("Cannot set isAllowedToSetRegistryLockPassword through UI");
|
throw new FormException(
|
||||||
|
"Cannot modify isAllowedToSetRegistryLockPassword through the UI");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -180,7 +180,8 @@ registry.json.RegistrarAddress;
|
||||||
* faxNumber: (string?|undefined),
|
* faxNumber: (string?|undefined),
|
||||||
* types: (string?|undefined),
|
* types: (string?|undefined),
|
||||||
* allowedToSetRegistryLockPassword: boolean,
|
* allowedToSetRegistryLockPassword: boolean,
|
||||||
* registryLockAllowed: boolean
|
* registryLockAllowed: boolean,
|
||||||
|
* registryLockEmailAddress: (string?|undefined)
|
||||||
* }}
|
* }}
|
||||||
*/
|
*/
|
||||||
registry.json.RegistrarContact;
|
registry.json.RegistrarContact;
|
||||||
|
|
|
@ -176,6 +176,10 @@
|
||||||
{if isNonnull($item['gaeUserId'])}
|
{if isNonnull($item['gaeUserId'])}
|
||||||
<input type="hidden" name="{$namePrefix}gaeUserId" value="{$item['gaeUserId']}">
|
<input type="hidden" name="{$namePrefix}gaeUserId" value="{$item['gaeUserId']}">
|
||||||
{/if}
|
{/if}
|
||||||
|
{if isNonnull($item['registryLockEmailAddress'])}
|
||||||
|
<input type="hidden" name="{$namePrefix}registryLockEmailAddress"
|
||||||
|
value="{$item['registryLockEmailAddress']}">
|
||||||
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
{/template}
|
{/template}
|
||||||
|
|
||||||
|
|
|
@ -67,26 +67,28 @@ public class ContactSettingsTest extends RegistrarSettingsActionTestCase {
|
||||||
@Test
|
@Test
|
||||||
public void testPost_updateContacts_success() throws Exception {
|
public void testPost_updateContacts_success() throws Exception {
|
||||||
// Remove all the contacts but one by updating with a list of just it
|
// Remove all the contacts but one by updating with a list of just it
|
||||||
ImmutableMap<String, String> adminContact1 =
|
Map<String, Object> adminContact =
|
||||||
ImmutableMap.of(
|
loadRegistrar(CLIENT_ID).getContacts().stream()
|
||||||
"name", "Marla Singer",
|
.filter(rc -> rc.getEmailAddress().equals("Marla.Singer@crr.com"))
|
||||||
"emailAddress", "Marla.Singer@crr.com",
|
.findFirst()
|
||||||
"phoneNumber", "+1.2128675309",
|
.get()
|
||||||
// Have to keep ADMIN or else expect FormException for at-least-one.
|
.toJsonMap();
|
||||||
"types", "ADMIN,TECH");
|
|
||||||
|
// Keep an admin to avoid superfluous issues
|
||||||
|
adminContact.put("types", "ADMIN,TECH");
|
||||||
|
|
||||||
Registrar registrar = loadRegistrar(CLIENT_ID);
|
Registrar registrar = loadRegistrar(CLIENT_ID);
|
||||||
Map<String, Object> regMap = registrar.toJsonMap();
|
Map<String, Object> regMap = registrar.toJsonMap();
|
||||||
regMap.put("contacts", ImmutableList.of(adminContact1));
|
regMap.put("contacts", ImmutableList.of(adminContact));
|
||||||
Map<String, Object> response =
|
Map<String, Object> response =
|
||||||
action.handleJsonRequest(ImmutableMap.of("op", "update", "id", CLIENT_ID, "args", regMap));
|
action.handleJsonRequest(ImmutableMap.of("op", "update", "id", CLIENT_ID, "args", regMap));
|
||||||
assertThat(response).containsEntry("status", "SUCCESS");
|
assertThat(response).containsEntry("status", "SUCCESS");
|
||||||
|
|
||||||
RegistrarContact foundContact =
|
RegistrarContact foundContact =
|
||||||
Iterables.getOnlyElement(loadRegistrar(CLIENT_ID).getContacts());
|
Iterables.getOnlyElement(loadRegistrar(CLIENT_ID).getContacts());
|
||||||
assertThat(foundContact.getName()).isEqualTo(adminContact1.get("name"));
|
assertThat(foundContact.getName()).isEqualTo(adminContact.get("name"));
|
||||||
assertThat(foundContact.getEmailAddress()).isEqualTo(adminContact1.get("emailAddress"));
|
assertThat(foundContact.getEmailAddress()).isEqualTo(adminContact.get("emailAddress"));
|
||||||
assertThat(foundContact.getPhoneNumber()).isEqualTo(adminContact1.get("phoneNumber"));
|
assertThat(foundContact.getPhoneNumber()).isEqualTo(adminContact.get("phoneNumber"));
|
||||||
assertThat(foundContact.getTypes()).containsExactly(Type.ADMIN, Type.TECH);
|
assertThat(foundContact.getTypes()).containsExactly(Type.ADMIN, Type.TECH);
|
||||||
assertMetric(CLIENT_ID, "update", "[OWNER]", "SUCCESS");
|
assertMetric(CLIENT_ID, "update", "[OWNER]", "SUCCESS");
|
||||||
verifyNotificationEmailsSent();
|
verifyNotificationEmailsSent();
|
||||||
|
@ -272,7 +274,7 @@ public class ContactSettingsTest extends RegistrarSettingsActionTestCase {
|
||||||
"results",
|
"results",
|
||||||
ImmutableList.of(),
|
ImmutableList.of(),
|
||||||
"message",
|
"message",
|
||||||
"Not allowed to set registry lock password directly on new contact");
|
"Cannot set registry lock password directly on new contact");
|
||||||
assertMetric(CLIENT_ID, "update", "[OWNER]", "ERROR: FormException");
|
assertMetric(CLIENT_ID, "update", "[OWNER]", "ERROR: FormException");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -323,7 +325,39 @@ public class ContactSettingsTest extends RegistrarSettingsActionTestCase {
|
||||||
"results",
|
"results",
|
||||||
ImmutableList.of(),
|
ImmutableList.of(),
|
||||||
"message",
|
"message",
|
||||||
"Cannot set isAllowedToSetRegistryLockPassword through UI");
|
"Cannot modify isAllowedToSetRegistryLockPassword through the UI");
|
||||||
|
assertMetric(CLIENT_ID, "update", "[OWNER]", "ERROR: FormException");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testPost_failure_setRegistryLockEmail() {
|
||||||
|
addPasswordToContactTwo();
|
||||||
|
Map<String, Object> reqJson = loadRegistrar(CLIENT_ID).toJsonMap();
|
||||||
|
String emailAddress = AppEngineRule.makeRegistrarContact2().getEmailAddress();
|
||||||
|
RegistrarContact newContactWithPassword =
|
||||||
|
loadRegistrar(CLIENT_ID).getContacts().stream()
|
||||||
|
.filter(rc -> rc.getEmailAddress().equals(emailAddress))
|
||||||
|
.findFirst()
|
||||||
|
.get();
|
||||||
|
Map<String, Object> contactJson = newContactWithPassword.toJsonMap();
|
||||||
|
contactJson.put("registryLockEmailAddress", "bogus.email@bogus.tld");
|
||||||
|
reqJson.put(
|
||||||
|
"contacts",
|
||||||
|
ImmutableList.of(
|
||||||
|
AppEngineRule.makeRegistrarContact1().toJsonMap(),
|
||||||
|
contactJson,
|
||||||
|
AppEngineRule.makeRegistrarContact3().toJsonMap()));
|
||||||
|
|
||||||
|
Map<String, Object> response =
|
||||||
|
action.handleJsonRequest(ImmutableMap.of("op", "update", "id", CLIENT_ID, "args", reqJson));
|
||||||
|
assertThat(response)
|
||||||
|
.containsExactly(
|
||||||
|
"status",
|
||||||
|
"ERROR",
|
||||||
|
"results",
|
||||||
|
ImmutableList.of(),
|
||||||
|
"message",
|
||||||
|
"Cannot modify registryLockEmailAddress through the UI");
|
||||||
assertMetric(CLIENT_ID, "update", "[OWNER]", "ERROR: FormException");
|
assertMetric(CLIENT_ID, "update", "[OWNER]", "ERROR: FormException");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
|
|
||||||
package google.registry.webdriver;
|
package google.registry.webdriver;
|
||||||
|
|
||||||
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
import static google.registry.server.Fixture.BASIC;
|
import static google.registry.server.Fixture.BASIC;
|
||||||
import static google.registry.server.Route.route;
|
import static google.registry.server.Route.route;
|
||||||
import static google.registry.testing.AppEngineRule.makeRegistrar2;
|
import static google.registry.testing.AppEngineRule.makeRegistrar2;
|
||||||
|
@ -32,11 +33,13 @@ import com.googlecode.objectify.ObjectifyFilter;
|
||||||
import google.registry.model.domain.DomainBase;
|
import google.registry.model.domain.DomainBase;
|
||||||
import google.registry.model.ofy.OfyFilter;
|
import google.registry.model.ofy.OfyFilter;
|
||||||
import google.registry.model.registrar.Registrar.State;
|
import google.registry.model.registrar.Registrar.State;
|
||||||
|
import google.registry.model.registrar.RegistrarContact;
|
||||||
import google.registry.module.frontend.FrontendServlet;
|
import google.registry.module.frontend.FrontendServlet;
|
||||||
import google.registry.schema.domain.RegistryLock;
|
import google.registry.schema.domain.RegistryLock;
|
||||||
import google.registry.server.RegistryTestServer;
|
import google.registry.server.RegistryTestServer;
|
||||||
import google.registry.testing.AppEngineRule;
|
import google.registry.testing.AppEngineRule;
|
||||||
import google.registry.testing.CertificateSamples;
|
import google.registry.testing.CertificateSamples;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -150,13 +153,13 @@ public class RegistrarConsoleScreenshotTest extends WebDriverTestCase {
|
||||||
public void settingsContactEdit_setRegistryLockPassword() throws Throwable {
|
public void settingsContactEdit_setRegistryLockPassword() throws Throwable {
|
||||||
server.runInAppEngineEnvironment(
|
server.runInAppEngineEnvironment(
|
||||||
() -> {
|
() -> {
|
||||||
|
persistResource(makeRegistrar2().asBuilder().setRegistryLockAllowed(true).build());
|
||||||
persistResource(
|
persistResource(
|
||||||
makeRegistrarContact2()
|
makeRegistrarContact2()
|
||||||
.asBuilder()
|
.asBuilder()
|
||||||
.setRegistryLockEmailAddress("johndoe.registrylock@example.com")
|
.setRegistryLockEmailAddress("johndoe.registrylock@example.com")
|
||||||
.setAllowedToSetRegistryLockPassword(true)
|
.setAllowedToSetRegistryLockPassword(true)
|
||||||
.build());
|
.build());
|
||||||
persistResource(makeRegistrar2().asBuilder().setRegistryLockAllowed(true).build());
|
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
driver.manage().window().setSize(new Dimension(1050, 2000));
|
driver.manage().window().setSize(new Dimension(1050, 2000));
|
||||||
|
@ -165,6 +168,25 @@ public class RegistrarConsoleScreenshotTest extends WebDriverTestCase {
|
||||||
driver.waitForElement(By.tagName("h1"));
|
driver.waitForElement(By.tagName("h1"));
|
||||||
driver.waitForElement(By.id("reg-app-btn-edit")).click();
|
driver.waitForElement(By.id("reg-app-btn-edit")).click();
|
||||||
driver.diffPage("page");
|
driver.diffPage("page");
|
||||||
|
|
||||||
|
// now actually set the password
|
||||||
|
driver.findElement(By.id("contacts[1].registryLockPassword")).sendKeys("password");
|
||||||
|
driver.waitForElement(By.id("reg-app-btn-save")).click();
|
||||||
|
Thread.sleep(500);
|
||||||
|
driver.diffPage("contactview");
|
||||||
|
|
||||||
|
server.runInAppEngineEnvironment(
|
||||||
|
() -> {
|
||||||
|
RegistrarContact contact =
|
||||||
|
loadRegistrar("TheRegistrar").getContacts().stream()
|
||||||
|
.filter(c -> c.getEmailAddress().equals("johndoe@theregistrar.com"))
|
||||||
|
.findFirst()
|
||||||
|
.get();
|
||||||
|
assertThat(contact.verifyRegistryLockPassword("password")).isTrue();
|
||||||
|
assertThat(contact.getRegistryLockEmailAddress())
|
||||||
|
.isEqualTo(Optional.of("johndoe.registrylock@example.com"));
|
||||||
|
return null;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 44 KiB |
Loading…
Add table
Reference in a new issue