diff --git a/bubble-server/src/main/java/bubble/ApiConstants.java b/bubble-server/src/main/java/bubble/ApiConstants.java index d764bc5d..33b7810c 100644 --- a/bubble-server/src/main/java/bubble/ApiConstants.java +++ b/bubble-server/src/main/java/bubble/ApiConstants.java @@ -294,8 +294,8 @@ public class ApiConstants { public static final int ERROR_MAX_BEFORE_ELLIPSES = 19900; public static final String API_TAG_ACTIVATION = "activation"; - public static final String API_TAG_AUTH = "auth"; - public static final String API_TAG_ACCOUNT = "account"; + public static final String API_TAG_AUTH = "authentication / authorization"; + public static final String API_TAG_ACCOUNT = "account management"; public static final String API_TAG_ACCOUNT_OBJECTS = "account-owned objects"; public static final String API_TAG_APPS = "bubble apps"; public static final String API_TAG_DEVICES = "devices"; diff --git a/bubble-server/src/main/java/bubble/dao/account/AccountDAO.java b/bubble-server/src/main/java/bubble/dao/account/AccountDAO.java index c6108c36..f9e7e091 100644 --- a/bubble-server/src/main/java/bubble/dao/account/AccountDAO.java +++ b/bubble-server/src/main/java/bubble/dao/account/AccountDAO.java @@ -18,7 +18,10 @@ import bubble.dao.device.DeviceDAO; import bubble.model.account.*; import bubble.model.app.*; import bubble.model.bill.BubblePlan; -import bubble.model.cloud.*; +import bubble.model.cloud.BubbleDomain; +import bubble.model.cloud.BubbleNetwork; +import bubble.model.cloud.BubbleNode; +import bubble.model.cloud.CloudService; import bubble.server.BubbleConfiguration; import bubble.service.SearchService; import bubble.service.account.SyncAccountService; @@ -46,8 +49,6 @@ import java.util.Map; import java.util.concurrent.atomic.AtomicBoolean; import static bubble.ApiConstants.getRemoteHost; -import static bubble.model.account.Account.ROOT_EMAIL; -import static bubble.model.account.Account.ROOT_USERNAME; import static bubble.model.account.AccountTemplate.copyTemplateObjects; import static bubble.model.account.AutoUpdatePolicy.EMPTY_AUTO_UPDATE_POLICY; import static bubble.server.BubbleConfiguration.getDEFAULT_LOCALE; @@ -99,7 +100,6 @@ public class AccountDAO extends AbstractCRUDDAO implements SqlViewSearc } public Account findByEmail(String email) { - if (email.equals(ROOT_EMAIL)) email = ROOT_USERNAME; return findByUniqueField("email", email.trim()); } diff --git a/bubble-server/src/main/java/bubble/resources/account/AccountsResource.java b/bubble-server/src/main/java/bubble/resources/account/AccountsResource.java index 5a0305a1..30f2d50d 100644 --- a/bubble-server/src/main/java/bubble/resources/account/AccountsResource.java +++ b/bubble-server/src/main/java/bubble/resources/account/AccountsResource.java @@ -845,7 +845,6 @@ public class AccountsResource { this.caller = userPrincipal(ctx); this.id = id; if (id != null) { - if (id.equals(ROOT_EMAIL)) id = ROOT_USERNAME; account = accountDAO.findById(id); if (account == null) { if (okNotFound) return; diff --git a/bubble-server/src/test/java/bubble/test/ActivatedBubbleModelTestBase.java b/bubble-server/src/test/java/bubble/test/ActivatedBubbleModelTestBase.java index 68611e91..c3000d1d 100644 --- a/bubble-server/src/test/java/bubble/test/ActivatedBubbleModelTestBase.java +++ b/bubble-server/src/test/java/bubble/test/ActivatedBubbleModelTestBase.java @@ -36,7 +36,6 @@ import java.util.stream.Collectors; import static bubble.ApiConstants.*; import static bubble.model.account.Account.ROOT_EMAIL; -import static bubble.model.account.Account.ROOT_USERNAME; import static org.cobbzilla.util.daemon.ZillaRuntime.*; import static org.cobbzilla.util.handlebars.HandlebarsUtil.applyReflectively; import static org.cobbzilla.util.io.StreamUtil.stream2string; @@ -80,7 +79,7 @@ public abstract class ActivatedBubbleModelTestBase extends BubbleModelTestBase { @Override protected @NonNull Map modelTest(final String name, ApiRunner apiRunner) throws Exception { getApi().logout(); - final Account root = getApi().post(AUTH_ENDPOINT + EP_LOGIN, new LoginRequest(ROOT_USERNAME, ROOT_PASSWORD), Account.class); + final Account root = getApi().post(AUTH_ENDPOINT + EP_LOGIN, new LoginRequest(ROOT_EMAIL, ROOT_PASSWORD), Account.class); if (empty(root.getToken())) die("modelTest: error logging in root user (was MFA configured in a previous test?): "+json(root)); getApi().pushToken(root.getToken()); apiRunner.addNamedSession(ROOT_SESSION, root.getToken()); @@ -133,7 +132,7 @@ public abstract class ActivatedBubbleModelTestBase extends BubbleModelTestBase { } catch (ValidationException e) { if (e.hasViolations() && e.getViolations().containsKey("err.activation.alreadyDone")) { log.warn("onStart: activation already done, trying to login: " + shortError(e)); - admin = client.post(AUTH_ENDPOINT + EP_LOGIN, new LoginRequest(ROOT_USERNAME, ROOT_PASSWORD), Account.class); + admin = client.post(AUTH_ENDPOINT + EP_LOGIN, new LoginRequest(ROOT_EMAIL, ROOT_PASSWORD), Account.class); } else { throw e; } diff --git a/bubble-server/src/test/java/bubble/test/live/S3StorageTest.java b/bubble-server/src/test/java/bubble/test/live/S3StorageTest.java index c8946716..6d24191b 100644 --- a/bubble-server/src/test/java/bubble/test/live/S3StorageTest.java +++ b/bubble-server/src/test/java/bubble/test/live/S3StorageTest.java @@ -31,7 +31,7 @@ import java.util.List; import static bubble.ApiConstants.*; import static bubble.cloud.storage.StorageCryptStream.MIN_DISTINCT_LENGTH; import static bubble.cloud.storage.StorageCryptStream.MIN_KEY_LENGTH; -import static bubble.model.account.Account.ROOT_USERNAME; +import static bubble.model.account.Account.ROOT_EMAIL; import static bubble.model.cloud.CloudCredentials.PARAM_KEY; import static org.apache.commons.lang3.RandomStringUtils.randomAlphanumeric; import static org.cobbzilla.util.daemon.ZillaRuntime.die; @@ -73,7 +73,7 @@ public class S3StorageTest extends NetworkTestBase { cloudDAO.update(s3cloud.setDriverConfigJson(json(config.setListFetchSize(LIST_FETCH_SIZE)))); comment = "login, start api session"; - final Account root = getApi().post(AUTH_ENDPOINT + EP_LOGIN, new LoginRequest(ROOT_USERNAME, ROOT_PASSWORD), Account.class); + final Account root = getApi().post(AUTH_ENDPOINT + EP_LOGIN, new LoginRequest(ROOT_EMAIL, ROOT_PASSWORD), Account.class); if (empty(root.getToken())) die("modelTest: error logging in root user (was MFA configured in a previous test?): "+json(root)); getApi().pushToken(root.getToken()); diff --git a/bubble-server/src/test/resources/models/include/fork.json b/bubble-server/src/test/resources/models/include/fork.json index 05bcb426..f5878c12 100644 --- a/bubble-server/src/test/resources/models/include/fork.json +++ b/bubble-server/src/test/resources/models/include/fork.json @@ -3,7 +3,7 @@ "comment": "declare default parameters for fork test part", "include": "_defaults", "params": { - "rootUsername": "root", + "rootUsername": "root@local.local", "rootPassword": "password1!", "email": "user-<>@example.com", "planVar": "plan", @@ -25,7 +25,7 @@ "comment": "add email contact for root user", "include": "add_approved_contact", "params": { - "username": "root", + "username": "root@local.local", "userSession": "rootSession", "contactInfo": "<>", "contactLookup": "<>" diff --git a/bubble-server/src/test/resources/models/include/new_bubble.json b/bubble-server/src/test/resources/models/include/new_bubble.json index 1473d844..e61484e8 100644 --- a/bubble-server/src/test/resources/models/include/new_bubble.json +++ b/bubble-server/src/test/resources/models/include/new_bubble.json @@ -3,7 +3,7 @@ "comment": "declare default parameters for new_bubble test part", "include": "_defaults", "params": { - "rootUsername": "root", + "rootUsername": "root@local.local", "rootPassword": "password1!", "sageFqdn": "_required", "sageConnectionVar": "sageConnection", diff --git a/bubble-server/src/test/resources/models/system/account_testDevice.json b/bubble-server/src/test/resources/models/system/account_testDevice.json index 5afde9cb..232bb98d 100644 --- a/bubble-server/src/test/resources/models/system/account_testDevice.json +++ b/bubble-server/src/test/resources/models/system/account_testDevice.json @@ -1,6 +1,6 @@ [ { - "email": "root", + "uuid": "root@local.local", "children": { "Device": [ {"name": "test", "deviceType": "other"} ] } diff --git a/bubble-server/src/test/resources/models/system/cloudService.json b/bubble-server/src/test/resources/models/system/cloudService.json index a11bd789..c3ab4fc4 100644 --- a/bubble-server/src/test/resources/models/system/cloudService.json +++ b/bubble-server/src/test/resources/models/system/cloudService.json @@ -256,7 +256,7 @@ "vars": [{"name": "DIGITALOCEAN_API_KEY", "value": "[[credentials.apiKey]]"}], "builder": { "type": "digitalocean", - "ssh_username": "root", + "ssh_username": "root@local.local", "api_token": "[[user `DIGITALOCEAN_API_KEY`]]", "image": "ubuntu-18-04-x64", "region": "<>", diff --git a/bubble-server/src/test/resources/models/tests/auth/basic_auth.json b/bubble-server/src/test/resources/models/tests/auth/basic_auth.json index 41a65a08..25cf4875 100644 --- a/bubble-server/src/test/resources/models/tests/auth/basic_auth.json +++ b/bubble-server/src/test/resources/models/tests/auth/basic_auth.json @@ -25,7 +25,7 @@ "session": "new", "uri": "auth/login", "entity": { - "name": "root", + "name": "root@local.local", "password": "password1!" } }, diff --git a/bubble-server/src/test/resources/models/tests/auth/change_admin_password.json b/bubble-server/src/test/resources/models/tests/auth/change_admin_password.json index 7efa14f3..e1c91b59 100644 --- a/bubble-server/src/test/resources/models/tests/auth/change_admin_password.json +++ b/bubble-server/src/test/resources/models/tests/auth/change_admin_password.json @@ -12,7 +12,7 @@ "comment": "update root policy, add authenticator", "include": "add_authenticator", "params": { - "userId": "root", + "userId": "root@local.local", "authenticatorVar": "rootAuthenticator" } }, @@ -112,7 +112,7 @@ "session": "new", "uri": "auth/login", "entity": { - "name": "root", + "name": "root@local.local", "password": "password1!" } }, @@ -127,7 +127,7 @@ "session": "new", "uri": "auth/login", "entity": { - "name": "root", + "name": "root@local.local", "password": "aNewRootPass1!", "totpToken": "{{authenticator_token rootAuthenticator.totpKey}}" } diff --git a/bubble-server/src/test/resources/models/tests/auth/change_password.json b/bubble-server/src/test/resources/models/tests/auth/change_password.json index 905ad693..8cb533d1 100644 --- a/bubble-server/src/test/resources/models/tests/auth/change_password.json +++ b/bubble-server/src/test/resources/models/tests/auth/change_password.json @@ -5,7 +5,7 @@ "session": "new", "uri": "auth/login", "entity": { - "name": "root", + "name": "root@local.local", "password": "password1!" } }, @@ -37,7 +37,7 @@ "session": "new", "uri": "auth/login", "entity": { - "name": "root", + "name": "root@local.local", "password": "password1!" } }, @@ -52,7 +52,7 @@ "session": "new", "uri": "auth/login", "entity": { - "name": "root", + "name": "root@local.local", "password": "password2!" } }, @@ -74,7 +74,7 @@ "comment": "update root policy, add authenticator", "include": "add_authenticator", "params": { - "userId": "root", + "userId": "root@local.local", "authenticatorVar": "rootAuthenticator" } }, @@ -125,7 +125,7 @@ "session": "new", "uri": "auth/login", "entity": { - "name": "root", + "name": "root@local.local", "password": "password3!", "totpToken": "{{authenticator_token rootAuthenticator.totpKey}}" } diff --git a/bubble-server/src/test/resources/models/tests/auth/network_auth.json b/bubble-server/src/test/resources/models/tests/auth/network_auth.json index 23d33def..5d1a9934 100644 --- a/bubble-server/src/test/resources/models/tests/auth/network_auth.json +++ b/bubble-server/src/test/resources/models/tests/auth/network_auth.json @@ -3,7 +3,7 @@ "comment": "add email contact for root user", "include": "add_approved_contact", "params": { - "username": "root", + "username": "root@local.local", "userSession": "rootSession", "contactInfo": "root@example.com", "contactLookup": "root@example.com" @@ -14,7 +14,7 @@ "comment": "add authenticator as required auth factor", "include": "add_authenticator", "params": { - "userId": "root", + "userId": "root@local.local", "authFactor": "required" } }, @@ -58,7 +58,7 @@ "request": { "uri": "auth/authenticator", "entity": { - "account": "root", + "account": "root@local.local", "token": "{{authenticator_token authenticator.totpKey}}", "authenticate": true } @@ -132,7 +132,7 @@ "request": { "uri": "auth/authenticator", "entity": { - "account": "root", + "account": "root@local.local", "token": "{{authenticator_token authenticator.totpKey}}", "authenticate": true } diff --git a/bubble-server/src/test/resources/models/tests/live/backup_and_restore.json b/bubble-server/src/test/resources/models/tests/live/backup_and_restore.json index 29107cd1..d8a2c18d 100644 --- a/bubble-server/src/test/resources/models/tests/live/backup_and_restore.json +++ b/bubble-server/src/test/resources/models/tests/live/backup_and_restore.json @@ -10,7 +10,7 @@ "session": "new", "uri": "auth/login", "entity": { - "username": "root", + "username": "root@local.local", "password": "{{sageRootPass}}" } }, @@ -25,7 +25,7 @@ "comment": "add root@example.com as email contact for root user, if not already present", "include": "add_approved_contact", "params": { - "username": "root", + "username": "root@local.local", "userSession": "nnRootSession", "userConnection": "sageConnection", "rootSession": "nnRootSession", diff --git a/bubble-server/src/test/resources/models/tests/live/fork_sage.json b/bubble-server/src/test/resources/models/tests/live/fork_sage.json index 0f597f36..0f001af5 100644 --- a/bubble-server/src/test/resources/models/tests/live/fork_sage.json +++ b/bubble-server/src/test/resources/models/tests/live/fork_sage.json @@ -22,7 +22,7 @@ "session": "new", "uri": "auth/login", "entity": { - "name": "root", + "name": "root@local.local", "password": "{{sageRootPass}}" } }, diff --git a/bubble-server/src/test/resources/models/tests/network/network_keys.json b/bubble-server/src/test/resources/models/tests/network/network_keys.json index 9f4e57e7..d1abd4b5 100644 --- a/bubble-server/src/test/resources/models/tests/network/network_keys.json +++ b/bubble-server/src/test/resources/models/tests/network/network_keys.json @@ -3,7 +3,7 @@ "comment": "add email contact for root user", "include": "add_approved_contact", "params": { - "username": "root", + "username": "root@local.local", "userSession": "rootSession", "contactInfo": "root@example.com", "contactLookup": "root@example.com" @@ -127,7 +127,7 @@ "comment": "add sms as required for node operations", "include": "add_approved_contact", "params": { - "username": "root", + "username": "root@local.local", "userSession": "rootSession", "contactType": "sms", "contactInfo": "US:800-555-1212",