From ff338a72e3b8c375c3a9df8e9c62e98a96e4d417 Mon Sep 17 00:00:00 2001 From: Michael Gilardi <11632652+mgilardi@users.noreply.github.com> Date: Sat, 14 Nov 2026 11:04:09 -0700 Subject: [PATCH 1/3] Rename Mapkeeper to BlueMapAuth (0.2.0) D194: named so people looking for BlueMap add-ons find it. The package, plugin, jar, command, permission and the map cookie are now BlueMapAuth. On first start the old plugins/Mapkeeper folder is copied across, and /mapkeeper and mapkeeper.admin keep working for 0.2.x. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/release.yml | 2 +- CLAUDE.md | 2 +- README.md | 25 ++++++---- build.gradle.kts | 6 +-- docs/decisions.md | 4 ++ docs/design.md | 12 ++--- docs/releases/v0.2.0.md | 12 +++++ settings.gradle.kts | 2 +- .../BlueMapAuthPlugin.java} | 29 ++++++----- .../com/extantape/bluemapauth/Migration.java | 48 +++++++++++++++++++ .../{mapkeeper => bluemapauth}/Setup.java | 6 +-- .../access/Access.java | 4 +- .../access/BlueMapWorlds.java | 2 +- .../access/LiveAccess.java | 4 +- .../access/OfflinePermissions.java | 2 +- .../web/ClientAddress.java | 2 +- .../web/JsonFilter.java | 2 +- .../web/MapServer.java | 8 ++-- .../{mapkeeper => bluemapauth}/web/Pages.java | 4 +- .../web/RateLimiter.java | 2 +- .../web/Sessions.java | 4 +- src/main/resources/config.yml | 8 ++-- src/main/resources/paper-plugin.yml | 15 ++++-- .../{mapkeeper => bluemapauth}/SetupTest.java | 2 +- .../web/BrowserDemo.java | 4 +- .../web/MapServerTest.java | 4 +- test/live/{mapkeeper.mjs => bluemapauth.mjs} | 34 ++++++------- test/live/package.json | 2 +- 28 files changed, 166 insertions(+), 85 deletions(-) create mode 100644 docs/releases/v0.2.0.md rename src/main/java/com/extantape/{mapkeeper/MapkeeperPlugin.java => bluemapauth/BlueMapAuthPlugin.java} (72%) create mode 100644 src/main/java/com/extantape/bluemapauth/Migration.java rename src/main/java/com/extantape/{mapkeeper => bluemapauth}/Setup.java (94%) rename src/main/java/com/extantape/{mapkeeper => bluemapauth}/access/Access.java (86%) rename src/main/java/com/extantape/{mapkeeper => bluemapauth}/access/BlueMapWorlds.java (94%) rename src/main/java/com/extantape/{mapkeeper => bluemapauth}/access/LiveAccess.java (97%) rename src/main/java/com/extantape/{mapkeeper => bluemapauth}/access/OfflinePermissions.java (95%) rename src/main/java/com/extantape/{mapkeeper => bluemapauth}/web/ClientAddress.java (98%) rename src/main/java/com/extantape/{mapkeeper => bluemapauth}/web/JsonFilter.java (98%) rename src/main/java/com/extantape/{mapkeeper => bluemapauth}/web/MapServer.java (98%) rename src/main/java/com/extantape/{mapkeeper => bluemapauth}/web/Pages.java (96%) rename src/main/java/com/extantape/{mapkeeper => bluemapauth}/web/RateLimiter.java (98%) rename src/main/java/com/extantape/{mapkeeper => bluemapauth}/web/Sessions.java (97%) rename src/test/java/com/extantape/{mapkeeper => bluemapauth}/SetupTest.java (98%) rename src/test/java/com/extantape/{mapkeeper => bluemapauth}/web/BrowserDemo.java (97%) rename src/test/java/com/extantape/{mapkeeper => bluemapauth}/web/MapServerTest.java (99%) rename test/live/{mapkeeper.mjs => bluemapauth.mjs} (93%) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f5ecac7..5036080 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -31,4 +31,4 @@ jobs: - name: Attach the jar to a GitHub Release env: GH_TOKEN: ${{ github.token }} - run: gh release create "$GITHUB_REF_NAME" build/libs/Mapkeeper-*.jar --title "Mapkeeper $GITHUB_REF_NAME" --notes-file "docs/releases/$GITHUB_REF_NAME.md" + run: gh release create "$GITHUB_REF_NAME" build/libs/BlueMapAuth-*.jar --title "BlueMapAuth $GITHUB_REF_NAME" --notes-file "docs/releases/$GITHUB_REF_NAME.md" diff --git a/CLAUDE.md b/CLAUDE.md index a50c48a..8af0acf 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -1,4 +1,4 @@ -# Mapkeeper +# BlueMapAuth Registered in the owner's ops process (`~/Code/ops`). Area: `minecraft-plugins`. Created 2026-11-10 from the ops starter kit. diff --git a/README.md b/README.md index b0681b5..c6b4f7d 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ -# Mapkeeper +# BlueMapAuth -Mapkeeper for Paper: BlueMap's web map behind a sign-in, showing each player only the worlds and players they're allowed to see. +BlueMapAuth for Paper: BlueMap's web map behind a sign-in, showing each player only the worlds and players they're allowed to see. -**Status:** early, version 0.1.0. 24 HTTP and config tests pass, plus a bot test (25/25, and 8/8 without HouseRules and LuckPerms, 2026-11-11) on a throwaway Paper 26.1.2 server with the real BlueMap 5.29, LuckPerms 5.5, HouseRules and Latchkey, signing in through Latchkey's "Open the map" over HTTP. The hand-off page was checked in a real browser (Chromium, 2026-11-11, against made-up data on localhost; `BrowserDemo` in the test sources). The token leaves the address bar, the cookie is invisible to scripts, a reused link explains itself, and the page has no policy errors. On a copy of a real server on Paper 26.2 and 26.3 build 249 (2026-11-14) it loaded with no errors, switched off, so serving the map on 26.2 and 26.3 is still untested, as is running behind Caddy. +**Status:** early, version 0.2.0, renamed from Mapkeeper (D194; see below). 24 HTTP and config tests pass, plus a bot test (25/25, and 8/8 without HouseRules and LuckPerms, 2026-11-11) on a throwaway Paper 26.1.2 server with the real BlueMap 5.29, LuckPerms 5.5, HouseRules and Latchkey, signing in through Latchkey's "Open the map" over HTTP. The hand-off page was checked in a real browser (Chromium, 2026-11-11, against made-up data on localhost; `BrowserDemo` in the test sources). The token leaves the address bar, the cookie is invisible to scripts, a reused link explains itself, and the page has no policy errors. On a copy of a real server on Paper 26.2 and 26.3 build 249 (2026-11-14) it loaded with no errors, switched off, so serving the map on 26.2 and 26.3 is still untested, as is running behind Caddy. ## What it does -- Serves BlueMap's web map at its own address, such as `map.example.org`, and nothing of it to anyone who isn't signed in. BlueMap's own web server stays on 127.0.0.1, so Mapkeeper is the only way in. +- Serves BlueMap's web map at its own address, such as `map.example.org`, and nothing of it to anyone who isn't signed in. BlueMap's own web server stays on 127.0.0.1, so BlueMapAuth is the only way in. - Signs a browser in with a one-time link from Latchkey's invite page ("Open the map"). The link works once, for a minute. The map then has its own cookie for its own address only, and it ends within 30 seconds of the Latchkey session ending. - Lists only the maps of worlds the viewer may enter (`multiverse.access.` by default). Any other map is "not found", the same as one that doesn't exist. - Shows only the players the viewer may see. In game, that's chat's reach from HouseRules. A viewer who isn't in game sees only players who share a HouseRules circle with them. @@ -20,16 +20,25 @@ Needs Paper 26.1 or newer and Java 25. BlueMap, LuckPerms, HouseRules (0.4 or ne ./gradlew build ``` -The jar is `build/libs/Mapkeeper-.jar`. In `plugins/Mapkeeper/config.yml`, set `enabled: true` and `public-url`. Point your HTTPS proxy at `127.0.0.1:8180`, and set BlueMap's web server to `ip: "127.0.0.1"`. In Latchkey, set `page.map-address` to the same address. +The jar is `build/libs/BlueMapAuth-.jar`. In `plugins/BlueMapAuth/config.yml`, set `enabled: true` and `public-url`. Point your HTTPS proxy at `127.0.0.1:8180`, and set BlueMap's web server to `ip: "127.0.0.1"`. In Latchkey, set `page.map-address` to the same address. ## Bot test -`test/live/mapkeeper.mjs` builds a throwaway server in a temp folder, runs bots and browser requests against it, and deletes it. The settings it needs are at the top of the file. `MK_TEST_MISSING=1` runs it without HouseRules and LuckPerms, to check those paths fail closed. It needs Node 22 or newer, and `npm ci` in `test/live` first. +`test/live/bluemapauth.mjs` builds a throwaway server in a temp folder, runs bots and browser requests against it, and deletes it. The settings it needs are at the top of the file. `MK_TEST_MISSING=1` runs it without HouseRules and LuckPerms, to check those paths fail closed. It needs Node 22 or newer, and `npm ci` in `test/live` first. ## Commands -- `/mapkeeper status`: whether the map is served, what's wrong with the config, and which plugins it found. Needs `mapkeeper.admin`. -- `/mapkeeper reload`: re-reads `config.yml`. +- `/bluemapauth status`: whether the map is served, what's wrong with the config, and which plugins it found. Needs `bluemapauth.admin`. +- `/bluemapauth reload`: re-reads `config.yml`. + +## Upgrading from Mapkeeper + +BlueMapAuth was called Mapkeeper up to 0.1.0, and renamed so people looking for BlueMap add-ons find it. Nothing else changed in how it works. + +- With the server stopped, swap `Mapkeeper-0.1.0.jar` for `BlueMapAuth-0.2.0.jar`. +- On its first start, BlueMapAuth copies `plugins/Mapkeeper/` to `plugins/BlueMapAuth/` if that doesn't exist yet. The old folder is left as it was. +- For 0.2.x only, `/mapkeeper` still works and `mapkeeper.admin` still grants `bluemapauth.admin`. Both go in the next release. +- Map sessions start again: the map's cookie has a new name, so anyone signed in to the map signs in once more through Latchkey. ## License diff --git a/build.gradle.kts b/build.gradle.kts index 819d6bd..70695c2 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -3,7 +3,7 @@ plugins { } group = "com.extantape" -version = "0.1.0" +version = "0.2.0" java { toolchain.languageVersion.set(JavaLanguageVersion.of(25)) @@ -21,7 +21,7 @@ val blueMapApi = "de.bluecolored:bluemap-api:2.7.8" val luckPermsApi = "net.luckperms:api:5.4" dependencies { - // All optional at run time: each is used only when its plugin is installed, and Mapkeeper fails closed without it. + // All optional at run time: each is used only when its plugin is installed, and BlueMapAuth fails closed without it. compileOnly(paperApi) compileOnly(blueMapApi) compileOnly(luckPermsApi) @@ -49,7 +49,7 @@ tasks.test { } tasks.jar { - archiveBaseName.set("Mapkeeper") + archiveBaseName.set("BlueMapAuth") } // Prints the test classpath, for running test/java's BrowserDemo by hand. diff --git a/docs/decisions.md b/docs/decisions.md index 83e843b..4e3c831 100644 --- a/docs/decisions.md +++ b/docs/decisions.md @@ -11,3 +11,7 @@ Dated decisions for this repo, newest last. ## 2026-11-14 - **First release and going public.** The owner approved release tags for the staged jars (Helm chat, 2026-11-14, "Go (Recommended)"), under the standing yes of 2026-11-07 for a private Minecraft plugin repo to go public at its first release. Before going public: a history audit (no secrets, private terms, server addresses or player data; only noreply commit emails; no build output), the leak check in CI, an MIT LICENSE and a README status line. + +## 2026-11-14 + +- **Name (owner, D194):** Mapkeeper is renamed BlueMapAuth, so people looking for BlueMap add-ons find it. The owner: "yes… BlueMapAuth". Released as 0.2.0, with the old folder copied on first start and `/mapkeeper` and `mapkeeper.admin` working for 0.2.x. diff --git a/docs/design.md b/docs/design.md index 29baff6..4514f4b 100644 --- a/docs/design.md +++ b/docs/design.md @@ -1,11 +1,11 @@ -# Mapkeeper design (2026-11-10) +# BlueMapAuth design (2026-11-10) -Mapkeeper puts BlueMap's web map behind a sign-in and shows each signed-in player only what they may see. Owner decisions: D40 (the name, its own agnostic plugin), D41 (players on the map follow chat's reach rules; anyone Mapkeeper can't check stays hidden), D54 (a viewer who isn't in game sees only players in their circles), D43 (its own address, `map.`, with its own host-only cookie from a one-time hand-off; never a cookie on the whole domain). +BlueMapAuth puts BlueMap's web map behind a sign-in and shows each signed-in player only what they may see. Owner decisions: D40 (the name, its own agnostic plugin), D41 (players on the map follow chat's reach rules; anyone BlueMapAuth can't check stays hidden), D54 (a viewer who isn't in game sees only players in their circles), D43 (its own address, `map.`, with its own host-only cookie from a one-time hand-off; never a cookie on the whole domain). ## Pieces ``` -browser ──https──▶ Caddy (map.) ──▶ Mapkeeper (127.0.0.1:8180) ──▶ BlueMap's web server (127.0.0.1:8100) +browser ──https──▶ Caddy (map.) ──▶ BlueMapAuth (127.0.0.1:8180) ──▶ BlueMap's web server (127.0.0.1:8100) │ in-process, by name: ├─ Latchkey: hand-off tokens, session still valid? ├─ BlueMap API: which world each map shows @@ -13,15 +13,15 @@ browser ──https──▶ Caddy (map.) ──▶ Mapkeeper (127.0.0.1 └─ HouseRules: may the viewer reach that player? ``` -- **Mapkeeper is the only way in.** BlueMap's own web server listens on 127.0.0.1 only. Mapkeeper also listens on 127.0.0.1 only, behind the same Caddy as the invite page. +- **BlueMapAuth is the only way in.** BlueMap's own web server listens on 127.0.0.1 only. BlueMapAuth also listens on 127.0.0.1 only, behind the same Caddy as the invite page. - **No hard dependencies** (D2). Latchkey, LuckPerms and HouseRules are each read by name. Without one, the part that needs it fails closed: no Latchkey means nobody can sign in; no permissions check means no maps; no HouseRules means no other players on the map. ## Signing in (D43) 1. On the invite page's welcome view, a signed-in player clicks **Open the map**. 2. Latchkey makes a one-time token for that player and that session: random, single use, good for 60 seconds, audience `map`. It redirects to `https://map./handoff#` (after `#`, so it never reaches a log). -3. The page posts the token to Mapkeeper, which asks Latchkey to redeem it (in-process). Latchkey answers with the player and the session it came from, once. -4. Mapkeeper sets its own cookie on `map.` only: HttpOnly, Secure, SameSite=Strict, no Domain attribute. It lasts no longer than the Latchkey session, and ends when that session ends: Mapkeeper asks Latchkey whether it's still valid (cached for 30 seconds), so a sign-out, a revoke or a whitelist removal reaches the map within 30 seconds. +3. The page posts the token to BlueMapAuth, which asks Latchkey to redeem it (in-process). Latchkey answers with the player and the session it came from, once. +4. BlueMapAuth sets its own cookie on `map.` only: HttpOnly, Secure, SameSite=Strict, no Domain attribute. It lasts no longer than the Latchkey session, and ends when that session ends: BlueMapAuth asks Latchkey whether it's still valid (cached for 30 seconds), so a sign-out, a revoke or a whitelist removal reaches the map within 30 seconds. ## What each viewer gets diff --git a/docs/releases/v0.2.0.md b/docs/releases/v0.2.0.md new file mode 100644 index 0000000..da16f3f --- /dev/null +++ b/docs/releases/v0.2.0.md @@ -0,0 +1,12 @@ +Mapkeeper is now BlueMapAuth (D194), so people looking for BlueMap add-ons find it. Nothing else changed in how it works. + +## Upgrading + +- Swap `Mapkeeper-0.1.0.jar` for `BlueMapAuth-0.2.0.jar` with the server stopped. +- On first start, BlueMapAuth copies `plugins/Mapkeeper/` to `plugins/BlueMapAuth/` if that doesn't exist yet. The old folder stays as it was. +- For 0.2.x only, `/mapkeeper` still works and `mapkeeper.admin` still grants `bluemapauth.admin`. +- The map's cookie has a new name, so anyone signed in to the map signs in once more through Latchkey. + +## Tested + +Unit and HTTP tests pass. The carry-over was checked on a throwaway server. diff --git a/settings.gradle.kts b/settings.gradle.kts index bf5ede6..5a5ad4e 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1 +1 @@ -rootProject.name = "Mapkeeper" +rootProject.name = "BlueMapAuth" diff --git a/src/main/java/com/extantape/mapkeeper/MapkeeperPlugin.java b/src/main/java/com/extantape/bluemapauth/BlueMapAuthPlugin.java similarity index 72% rename from src/main/java/com/extantape/mapkeeper/MapkeeperPlugin.java rename to src/main/java/com/extantape/bluemapauth/BlueMapAuthPlugin.java index 5b7405e..9b01efc 100644 --- a/src/main/java/com/extantape/mapkeeper/MapkeeperPlugin.java +++ b/src/main/java/com/extantape/bluemapauth/BlueMapAuthPlugin.java @@ -1,7 +1,7 @@ -package com.extantape.mapkeeper; +package com.extantape.bluemapauth; -import com.extantape.mapkeeper.access.LiveAccess; -import com.extantape.mapkeeper.web.MapServer; +import com.extantape.bluemapauth.access.LiveAccess; +import com.extantape.bluemapauth.web.MapServer; import io.papermc.paper.command.brigadier.BasicCommand; import io.papermc.paper.command.brigadier.CommandSourceStack; import io.papermc.paper.plugin.lifecycle.event.types.LifecycleEvents; @@ -15,11 +15,11 @@ import java.util.List; /** - * Mapkeeper: BlueMap's web map behind a sign-in (docs/design.md). Off until {@code enabled: true} and every setting is - * safe. {@code /mapkeeper status} says what's on and why not; {@code /mapkeeper reload} re-reads the config. + * BlueMapAuth: BlueMap's web map behind a sign-in (docs/design.md). Off until {@code enabled: true} and every setting is + * safe. {@code /bluemapauth status} says what's on and why not; {@code /bluemapauth reload} re-reads the config. */ -public final class MapkeeperPlugin extends JavaPlugin { - public static final String ADMIN = "mapkeeper.admin"; +public final class BlueMapAuthPlugin extends JavaPlugin { + public static final String ADMIN = "bluemapauth.admin"; private MapServer server; private LiveAccess access; @@ -28,10 +28,13 @@ public final class MapkeeperPlugin extends JavaPlugin { @Override public void onEnable() { + // Renamed from Mapkeeper (D194): bring its folder across once, before anything reads the config. + String moved = Migration.copyIfMissing(getDataFolder().toPath().resolveSibling("Mapkeeper"), getDataFolder().toPath()); + if (moved != null) getLogger().warning(moved); saveDefaultConfig(); start(); - getLifecycleManager().registerEventHandler(LifecycleEvents.COMMANDS, e -> e.registrar().register("mapkeeper", - "Mapkeeper's status, and reloading its settings.", List.of(), new BasicCommand() { + getLifecycleManager().registerEventHandler(LifecycleEvents.COMMANDS, e -> e.registrar().register("bluemapauth", + "BlueMapAuth's status, and reloading its settings.", List.of("mapkeeper") /* the old name, for 0.2.x only */, new BasicCommand() { @Override public void execute(CommandSourceStack source, String[] args) { command(source.getSender(), args); @@ -49,10 +52,10 @@ private void start() { reloadConfig(); Setup.Result r = Setup.read(getConfig()); problems = r.problems(); - if (!r.enabled()) { getLogger().info("Mapkeeper is off (enabled: false), so the map isn't served."); return; } + if (!r.enabled()) { getLogger().info("BlueMapAuth is off (enabled: false), so the map isn't served."); return; } if (!r.ok()) { for (String p : r.problems()) getLogger().severe(p); - getLogger().severe("Mapkeeper didn't start, so the map isn't served. Fix the lines above, then /mapkeeper reload."); + getLogger().severe("BlueMapAuth didn't start, so the map isn't served. Fix the lines above, then /bluemapauth reload."); return; } access = new LiveAccess(r.worldPermission(), getLogger(), System::currentTimeMillis); @@ -83,7 +86,7 @@ private void command(CommandSender to, String[] args) { case "reload" -> { stop(); start(); - to.sendMessage(Component.text(server != null ? "Mapkeeper reloaded and serving the map." : "Mapkeeper reloaded. The map isn't served: see /mapkeeper status.", + to.sendMessage(Component.text(server != null ? "BlueMapAuth reloaded and serving the map." : "BlueMapAuth reloaded. The map isn't served: see /bluemapauth status.", server != null ? NamedTextColor.GREEN : NamedTextColor.YELLOW)); } case "status" -> { @@ -95,7 +98,7 @@ private void command(CommandSender to, String[] args) { to.sendMessage(Component.text(name + ": " + (on ? "found" : "missing, so " + missing(name)), on ? NamedTextColor.WHITE : NamedTextColor.RED)); } } - default -> to.sendMessage(Component.text("Use /mapkeeper status or /mapkeeper reload.", NamedTextColor.RED)); + default -> to.sendMessage(Component.text("Use /bluemapauth status or /bluemapauth reload.", NamedTextColor.RED)); } } diff --git a/src/main/java/com/extantape/bluemapauth/Migration.java b/src/main/java/com/extantape/bluemapauth/Migration.java new file mode 100644 index 0000000..58d7152 --- /dev/null +++ b/src/main/java/com/extantape/bluemapauth/Migration.java @@ -0,0 +1,48 @@ +package com.extantape.bluemapauth; + +import java.io.IOException; +import java.io.UncheckedIOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.StandardCopyOption; +import java.util.stream.Stream; + +/** Carries a server's files over from the old plugin folder after the rename from Mapkeeper (D194, 2026-11-14). */ +final class Migration { + private Migration() {} + + /** + * Copies {@code old} to {@code now} if {@code now} doesn't exist and {@code old} is a folder. Copies into a + * temporary sibling first and renames it into place, so a crash halfway leaves no half-filled folder. + * + * @return a line for the log saying what happened, or null if there was nothing to do + */ + static String copyIfMissing(Path old, Path now) { + if (Files.exists(now) || !Files.isDirectory(old)) return null; + Path tmp = now.resolveSibling(now.getFileName() + ".migrating"); + try { + if (Files.exists(tmp)) deleteTree(tmp); + try (Stream all = Files.walk(old)) { + all.forEach(p -> { + Path to = tmp.resolve(old.relativize(p).toString()); + try { + if (Files.isDirectory(p)) Files.createDirectories(to); + else Files.copy(p, to, StandardCopyOption.COPY_ATTRIBUTES); + } catch (IOException e) { throw new UncheckedIOException(e); } + }); + } + Files.move(tmp, now, StandardCopyOption.ATOMIC_MOVE); + return "Copied plugins/" + old.getFileName() + " to plugins/" + now.getFileName() + + " (Mapkeeper is now called BlueMapAuth). The old folder was left untouched; delete it once you're happy."; + } catch (IOException | UncheckedIOException e) { + return "Couldn't copy plugins/" + old.getFileName() + " to plugins/" + now.getFileName() + ": " + e.getMessage() + + ". Copy it by hand while the server is stopped, or BlueMapAuth starts with a fresh config."; + } + } + + private static void deleteTree(Path root) throws IOException { + try (Stream all = Files.walk(root)) { + for (Path p : all.sorted(java.util.Comparator.reverseOrder()).toList()) Files.delete(p); + } + } +} diff --git a/src/main/java/com/extantape/mapkeeper/Setup.java b/src/main/java/com/extantape/bluemapauth/Setup.java similarity index 94% rename from src/main/java/com/extantape/mapkeeper/Setup.java rename to src/main/java/com/extantape/bluemapauth/Setup.java index 3f6d846..78f5c13 100644 --- a/src/main/java/com/extantape/mapkeeper/Setup.java +++ b/src/main/java/com/extantape/bluemapauth/Setup.java @@ -1,6 +1,6 @@ -package com.extantape.mapkeeper; +package com.extantape.bluemapauth; -import com.extantape.mapkeeper.web.MapServer; +import com.extantape.bluemapauth.web.MapServer; import org.bukkit.configuration.ConfigurationSection; import java.net.InetAddress; @@ -28,7 +28,7 @@ public static Result read(ConfigurationSection c) { boolean enabled = c.getBoolean("enabled", false); String bind = c.getString("bind", "127.0.0.1").strip(); - if (!bind.equals("127.0.0.1") && !bind.equals("::1")) problems.add("bind is \"" + bind + "\". Mapkeeper listens on this machine only: use 127.0.0.1 and put your HTTPS proxy in front."); + if (!bind.equals("127.0.0.1") && !bind.equals("::1")) problems.add("bind is \"" + bind + "\". BlueMapAuth listens on this machine only: use 127.0.0.1 and put your HTTPS proxy in front."); int port = c.getInt("port", 8180); if (port < 1 || port > 65535) problems.add("port " + port + " isn't a port number (1 to 65535)."); diff --git a/src/main/java/com/extantape/mapkeeper/access/Access.java b/src/main/java/com/extantape/bluemapauth/access/Access.java similarity index 86% rename from src/main/java/com/extantape/mapkeeper/access/Access.java rename to src/main/java/com/extantape/bluemapauth/access/Access.java index f6876dc..73c66d2 100644 --- a/src/main/java/com/extantape/mapkeeper/access/Access.java +++ b/src/main/java/com/extantape/bluemapauth/access/Access.java @@ -1,4 +1,4 @@ -package com.extantape.mapkeeper.access; +package com.extantape.bluemapauth.access; import java.util.Map; import java.util.Optional; @@ -6,7 +6,7 @@ import java.util.UUID; /** - * Everything Mapkeeper asks the rest of the server, in one place, so the web side can be tested with made-up answers. + * Everything BlueMapAuth asks the rest of the server, in one place, so the web side can be tested with made-up answers. * Every method must be safe from any thread, and must answer "no" (empty, false, nothing) when it can't be sure. */ public interface Access { diff --git a/src/main/java/com/extantape/mapkeeper/access/BlueMapWorlds.java b/src/main/java/com/extantape/bluemapauth/access/BlueMapWorlds.java similarity index 94% rename from src/main/java/com/extantape/mapkeeper/access/BlueMapWorlds.java rename to src/main/java/com/extantape/bluemapauth/access/BlueMapWorlds.java index e7bd6d7..d7b6566 100644 --- a/src/main/java/com/extantape/mapkeeper/access/BlueMapWorlds.java +++ b/src/main/java/com/extantape/bluemapauth/access/BlueMapWorlds.java @@ -1,4 +1,4 @@ -package com.extantape.mapkeeper.access; +package com.extantape.bluemapauth.access; import de.bluecolored.bluemap.api.BlueMapAPI; import org.bukkit.Bukkit; diff --git a/src/main/java/com/extantape/mapkeeper/access/LiveAccess.java b/src/main/java/com/extantape/bluemapauth/access/LiveAccess.java similarity index 97% rename from src/main/java/com/extantape/mapkeeper/access/LiveAccess.java rename to src/main/java/com/extantape/bluemapauth/access/LiveAccess.java index 0bbbc4b..e424f80 100644 --- a/src/main/java/com/extantape/mapkeeper/access/LiveAccess.java +++ b/src/main/java/com/extantape/bluemapauth/access/LiveAccess.java @@ -1,4 +1,4 @@ -package com.extantape.mapkeeper.access; +package com.extantape.bluemapauth.access; import org.bukkit.Bukkit; import org.bukkit.entity.Player; @@ -17,7 +17,7 @@ /** * The real answers, from the plugins on the server. Latchkey and HouseRules are called by method name with plain Java - * and Bukkit types, so Mapkeeper builds without them (D40). BlueMap and LuckPerms are used only when installed. Each + * and Bukkit types, so BlueMapAuth builds without them (D40). BlueMap and LuckPerms are used only when installed. Each * missing piece answers "no" (docs/design.md): *
    *
  • no Latchkey: nobody can sign in, and every map session ends at its next check;
  • diff --git a/src/main/java/com/extantape/mapkeeper/access/OfflinePermissions.java b/src/main/java/com/extantape/bluemapauth/access/OfflinePermissions.java similarity index 95% rename from src/main/java/com/extantape/mapkeeper/access/OfflinePermissions.java rename to src/main/java/com/extantape/bluemapauth/access/OfflinePermissions.java index 31129ca..ac60503 100644 --- a/src/main/java/com/extantape/mapkeeper/access/OfflinePermissions.java +++ b/src/main/java/com/extantape/bluemapauth/access/OfflinePermissions.java @@ -1,4 +1,4 @@ -package com.extantape.mapkeeper.access; +package com.extantape.bluemapauth.access; import net.luckperms.api.LuckPermsProvider; import net.luckperms.api.model.user.User; diff --git a/src/main/java/com/extantape/mapkeeper/web/ClientAddress.java b/src/main/java/com/extantape/bluemapauth/web/ClientAddress.java similarity index 98% rename from src/main/java/com/extantape/mapkeeper/web/ClientAddress.java rename to src/main/java/com/extantape/bluemapauth/web/ClientAddress.java index c67834d..470d535 100644 --- a/src/main/java/com/extantape/mapkeeper/web/ClientAddress.java +++ b/src/main/java/com/extantape/bluemapauth/web/ClientAddress.java @@ -1,4 +1,4 @@ -package com.extantape.mapkeeper.web; +package com.extantape.bluemapauth.web; import java.net.InetAddress; import java.util.List; diff --git a/src/main/java/com/extantape/mapkeeper/web/JsonFilter.java b/src/main/java/com/extantape/bluemapauth/web/JsonFilter.java similarity index 98% rename from src/main/java/com/extantape/mapkeeper/web/JsonFilter.java rename to src/main/java/com/extantape/bluemapauth/web/JsonFilter.java index 2336495..e771e52 100644 --- a/src/main/java/com/extantape/mapkeeper/web/JsonFilter.java +++ b/src/main/java/com/extantape/bluemapauth/web/JsonFilter.java @@ -1,4 +1,4 @@ -package com.extantape.mapkeeper.web; +package com.extantape.bluemapauth.web; import com.google.gson.JsonArray; import com.google.gson.JsonElement; diff --git a/src/main/java/com/extantape/mapkeeper/web/MapServer.java b/src/main/java/com/extantape/bluemapauth/web/MapServer.java similarity index 98% rename from src/main/java/com/extantape/mapkeeper/web/MapServer.java rename to src/main/java/com/extantape/bluemapauth/web/MapServer.java index 9e118ec..8c7b448 100644 --- a/src/main/java/com/extantape/mapkeeper/web/MapServer.java +++ b/src/main/java/com/extantape/bluemapauth/web/MapServer.java @@ -1,6 +1,6 @@ -package com.extantape.mapkeeper.web; +package com.extantape.bluemapauth.web; -import com.extantape.mapkeeper.access.Access; +import com.extantape.bluemapauth.access.Access; import com.sun.net.httpserver.Headers; import com.sun.net.httpserver.HttpExchange; import com.sun.net.httpserver.HttpServer; @@ -39,7 +39,7 @@ * the same as one that doesn't exist. */ public final class MapServer { - public static final String COOKIE = "mapkeeper"; + public static final String COOKIE = "bluemapauth"; static final Duration MIN_ANSWER = Duration.ofMillis(400); static final int MAX_JSON = 4 * 1024 * 1024; private static final int MAX_BODY = 256; @@ -240,7 +240,7 @@ private void pass(HttpExchange x, String path, String cache) throws IOException, // --- answers --- - /** BlueMap's web app needs scripts, workers and WebGL, so its pages get a looser policy than Mapkeeper's own. */ + /** BlueMap's web app needs scripts, workers and WebGL, so its pages get a looser policy than BlueMapAuth's own. */ static final String APP_CSP = "frame-ancestors 'none'; base-uri 'self'; form-action 'self'; object-src 'none'"; static void securityHeaders(Headers h, String csp) { diff --git a/src/main/java/com/extantape/mapkeeper/web/Pages.java b/src/main/java/com/extantape/bluemapauth/web/Pages.java similarity index 96% rename from src/main/java/com/extantape/mapkeeper/web/Pages.java rename to src/main/java/com/extantape/bluemapauth/web/Pages.java index 6a0bd81..7dc2761 100644 --- a/src/main/java/com/extantape/mapkeeper/web/Pages.java +++ b/src/main/java/com/extantape/bluemapauth/web/Pages.java @@ -1,4 +1,4 @@ -package com.extantape.mapkeeper.web; +package com.extantape.bluemapauth.web; import java.nio.charset.StandardCharsets; import java.security.MessageDigest; @@ -6,7 +6,7 @@ import java.util.Base64; /** - * Mapkeeper's own two pages: the hand-off that turns a one-time token into the map's own cookie, and the sign-in page a + * BlueMapAuth's own two pages: the hand-off that turns a one-time token into the map's own cookie, and the sign-in page a * visitor sees before that. Plain HTML that reads well with a screen reader, and works in light and dark. The one * script is allowed by its hash and nothing else is. */ diff --git a/src/main/java/com/extantape/mapkeeper/web/RateLimiter.java b/src/main/java/com/extantape/bluemapauth/web/RateLimiter.java similarity index 98% rename from src/main/java/com/extantape/mapkeeper/web/RateLimiter.java rename to src/main/java/com/extantape/bluemapauth/web/RateLimiter.java index 6f0d8f7..78cccaa 100644 --- a/src/main/java/com/extantape/mapkeeper/web/RateLimiter.java +++ b/src/main/java/com/extantape/bluemapauth/web/RateLimiter.java @@ -1,4 +1,4 @@ -package com.extantape.mapkeeper.web; +package com.extantape.bluemapauth.web; import java.util.ArrayDeque; import java.util.Deque; diff --git a/src/main/java/com/extantape/mapkeeper/web/Sessions.java b/src/main/java/com/extantape/bluemapauth/web/Sessions.java similarity index 97% rename from src/main/java/com/extantape/mapkeeper/web/Sessions.java rename to src/main/java/com/extantape/bluemapauth/web/Sessions.java index e5e1e13..13cdede 100644 --- a/src/main/java/com/extantape/mapkeeper/web/Sessions.java +++ b/src/main/java/com/extantape/bluemapauth/web/Sessions.java @@ -1,6 +1,6 @@ -package com.extantape.mapkeeper.web; +package com.extantape.bluemapauth.web; -import com.extantape.mapkeeper.access.Access; +import com.extantape.bluemapauth.access.Access; import java.nio.charset.StandardCharsets; import java.security.MessageDigest; diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 7e2b92a..0019cec 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -1,22 +1,22 @@ -# Mapkeeper: BlueMap's web map behind a sign-in. See docs/design.md. +# BlueMapAuth: BlueMap's web map behind a sign-in. See docs/design.md. # Off until you turn it on. enabled: false -# Where Mapkeeper listens. Keep it on this machine, behind your HTTPS proxy (such as Caddy). +# Where BlueMapAuth listens. Keep it on this machine, behind your HTTPS proxy (such as Caddy). bind: 127.0.0.1 port: 8180 # The map's public https:// address, such as https://map.example.org. Sign-in posts must come from here. public-url: "" -# BlueMap's own web server. It must listen on this machine only, so Mapkeeper is the only way in: +# BlueMap's own web server. It must listen on this machine only, so BlueMapAuth is the only way in: # in BlueMap's webserver.conf, set ip: "127.0.0.1". bluemap-url: "http://127.0.0.1:8100" # Where a visitor who isn't signed in is sent to sign in: your Latchkey invite page, such as https://example.org. sign-in-url: "" -# Exact addresses of the proxy in front of Mapkeeper. Only these are believed about a visitor's real address. +# Exact addresses of the proxy in front of BlueMapAuth. Only these are believed about a visitor's real address. trusted-proxies: - 127.0.0.1 diff --git a/src/main/resources/paper-plugin.yml b/src/main/resources/paper-plugin.yml index 653389c..94ba629 100644 --- a/src/main/resources/paper-plugin.yml +++ b/src/main/resources/paper-plugin.yml @@ -1,9 +1,9 @@ -name: Mapkeeper +name: BlueMapAuth version: '${version}' -main: com.extantape.mapkeeper.MapkeeperPlugin +main: com.extantape.bluemapauth.BlueMapAuthPlugin api-version: '26.1' description: BlueMap's web map behind a sign-in, showing each player only the worlds and players they may see. -website: https://github.com/ExtantApe/Mapkeeper +website: https://github.com/ExtantApe/BlueMapAuth # Every one of these is optional. Without one, the part that needs it fails closed (docs/design.md). dependencies: server: @@ -24,6 +24,11 @@ dependencies: required: false join-classpath: false permissions: - mapkeeper.admin: - description: Use /mapkeeper status and reload. + bluemapauth.admin: + description: Use /bluemapauth status and reload. default: op + mapkeeper.admin: + description: The old name for bluemapauth.admin, from before the rename (D194). It grants bluemapauth.admin, still works in 0.2.x, and is removed in the next release. + default: false + children: + bluemapauth.admin: true diff --git a/src/test/java/com/extantape/mapkeeper/SetupTest.java b/src/test/java/com/extantape/bluemapauth/SetupTest.java similarity index 98% rename from src/test/java/com/extantape/mapkeeper/SetupTest.java rename to src/test/java/com/extantape/bluemapauth/SetupTest.java index c564e31..d247c7b 100644 --- a/src/test/java/com/extantape/mapkeeper/SetupTest.java +++ b/src/test/java/com/extantape/bluemapauth/SetupTest.java @@ -1,4 +1,4 @@ -package com.extantape.mapkeeper; +package com.extantape.bluemapauth; import org.bukkit.configuration.file.YamlConfiguration; import org.junit.jupiter.api.Test; diff --git a/src/test/java/com/extantape/mapkeeper/web/BrowserDemo.java b/src/test/java/com/extantape/bluemapauth/web/BrowserDemo.java similarity index 97% rename from src/test/java/com/extantape/mapkeeper/web/BrowserDemo.java rename to src/test/java/com/extantape/bluemapauth/web/BrowserDemo.java index 4fbacce..21c16e1 100644 --- a/src/test/java/com/extantape/mapkeeper/web/BrowserDemo.java +++ b/src/test/java/com/extantape/bluemapauth/web/BrowserDemo.java @@ -1,6 +1,6 @@ -package com.extantape.mapkeeper.web; +package com.extantape.bluemapauth.web; -import com.extantape.mapkeeper.access.Access; +import com.extantape.bluemapauth.access.Access; import com.sun.net.httpserver.HttpServer; import java.net.InetAddress; diff --git a/src/test/java/com/extantape/mapkeeper/web/MapServerTest.java b/src/test/java/com/extantape/bluemapauth/web/MapServerTest.java similarity index 99% rename from src/test/java/com/extantape/mapkeeper/web/MapServerTest.java rename to src/test/java/com/extantape/bluemapauth/web/MapServerTest.java index 06c63a3..567cc8b 100644 --- a/src/test/java/com/extantape/mapkeeper/web/MapServerTest.java +++ b/src/test/java/com/extantape/bluemapauth/web/MapServerTest.java @@ -1,6 +1,6 @@ -package com.extantape.mapkeeper.web; +package com.extantape.bluemapauth.web; -import com.extantape.mapkeeper.access.Access; +import com.extantape.bluemapauth.access.Access; import com.sun.net.httpserver.HttpServer; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; diff --git a/test/live/mapkeeper.mjs b/test/live/bluemapauth.mjs similarity index 93% rename from test/live/mapkeeper.mjs rename to test/live/bluemapauth.mjs index 9b310a4..cbf5d25 100644 --- a/test/live/mapkeeper.mjs +++ b/test/live/bluemapauth.mjs @@ -1,4 +1,4 @@ -// Mapkeeper's bot test on a throwaway Paper 26.1.2 server with the real BlueMap, LuckPerms, HouseRules and Latchkey, +// BlueMapAuth's bot test on a throwaway Paper 26.1.2 server with the real BlueMap, LuckPerms, HouseRules and Latchkey, // driven from the console, over HTTP and with mineflayer bots. Built in a temp folder on 127.0.0.1, never a copy of a // real server, and deleted at the end, pass or fail. // @@ -22,7 +22,7 @@ import os from 'node:os' import path from 'node:path' import mineflayer from 'mineflayer' -const must = n => { const v = process.env[n]; if (!v) throw new Error('Set ' + n + ' (see the top of test/live/mapkeeper.mjs)'); return v } +const must = n => { const v = process.env[n]; if (!v) throw new Error('Set ' + n + ' (see the top of test/live/bluemapauth.mjs)'); return v } const JAVA = process.env.MK_TEST_JAVA ?? 'java' const MISSING = process.env.MK_TEST_MISSING === '1' const JARS = must('MK_TEST_JARS'), EULA = must('MK_TEST_EULA'), HOUSERULES = must('MK_TEST_HOUSERULES'), LATCHKEY = must('MK_TEST_LATCHKEY') @@ -32,8 +32,8 @@ if (![os.tmpdir(), '/tmp', '/private/tmp', '/var/folders'].map(p => path.resolve if (!/^eula=true$/m.test(readFileSync(EULA, 'utf8'))) throw new Error('That eula.txt isn\'t accepted. Accepting it is the owner\'s call.') const ROOT = new URL('../../', import.meta.url).pathname const LIBS = path.join(ROOT, 'build/libs') -const MK = readdirSync(LIBS).filter(f => /^Mapkeeper-[\d.]+\.jar$/.test(f)) -if (MK.length !== 1) throw new Error('Run ./gradlew clean build first: expected one Mapkeeper jar in build/libs') +const MK = readdirSync(LIBS).filter(f => /^BlueMapAuth-[\d.]+\.jar$/.test(f)) +if (MK.length !== 1) throw new Error('Run ./gradlew clean build first: expected one BlueMapAuth jar in build/libs') const PORT = 25618, LK_WEB = 25692, MAP_WEB = 25694, BLUEMAP = 25695 const PLAY = 'https://play.example.test', MAP = 'https://map.example.test' @@ -58,21 +58,21 @@ const KID = offlineUuid('Kid'), MUM = offlineUuid('Mum'), ADULT = offlineUuid('A // --- the server --- -const dir = path.join(RUN, 'mapkeeper-26.1.2') +const dir = path.join(RUN, 'bluemapauth-26.1.2') rmSync(dir, { recursive: true, force: true }) -for (const p of ['Latchkey', 'LuckPerms', 'HouseRules', 'Mapkeeper']) mkdirSync(path.join(dir, 'plugins', p), { recursive: true }) +for (const p of ['Latchkey', 'LuckPerms', 'HouseRules', 'BlueMapAuth']) mkdirSync(path.join(dir, 'plugins', p), { recursive: true }) copyFileSync(jar(/^paper-26\.1\.2\.jar$/), path.join(dir, 'paper.jar')) copyFileSync(EULA, path.join(dir, 'eula.txt')) if (!MISSING) copyFileSync(jar(/^LuckPerms-Bukkit-.*\.jar$/), path.join(dir, 'plugins/LuckPerms.jar')) copyFileSync(jar(/^bluemap-.*-paper\.jar$/), path.join(dir, 'plugins/BlueMap.jar')) if (!MISSING) copyFileSync(HOUSERULES, path.join(dir, 'plugins/HouseRules.jar')) copyFileSync(LATCHKEY, path.join(dir, 'plugins/Latchkey.jar')) -copyFileSync(path.join(LIBS, MK[0]), path.join(dir, 'plugins/Mapkeeper.jar')) +copyFileSync(path.join(LIBS, MK[0]), path.join(dir, 'plugins/BlueMapAuth.jar')) writeFileSync(path.join(dir, 'plugins/LuckPerms/config.yml'), 'server: global\nstorage-method: yaml\nwatch-files: false\n') writeFileSync(path.join(dir, 'server.properties'), [ 'server-ip=127.0.0.1', `server-port=${PORT}`, 'online-mode=false', 'white-list=true', 'enforce-whitelist=true', 'level-type=minecraft\\:flat', 'generate-structures=false', 'spawn-protection=0', 'enable-query=false', 'enable-rcon=false', - 'view-distance=4', 'simulation-distance=4', 'difficulty=peaceful', 'spawn-monsters=false', 'motd=Mapkeeper test'].join('\n') + '\n') + 'view-distance=4', 'simulation-distance=4', 'difficulty=peaceful', 'spawn-monsters=false', 'motd=BlueMapAuth test'].join('\n') + '\n') /** A plugin's shipped config with some lines replaced; each must still be there, so a changed default is noticed. */ function configFrom(src, dest, pairs) { @@ -90,7 +90,7 @@ configFrom(path.join(dir, 'lk.yml'), path.join(dir, 'plugins/Latchkey/config.yml ['map-address: ""', 'map-address: "' + MAP + '"']]) writeFileSync(path.join(dir, 'hr.yml'), await fromJar(HOUSERULES, 'config.yml')) configFrom(path.join(dir, 'hr.yml'), path.join(dir, 'plugins/HouseRules/config.yml'), [['circles: []', 'circles:\n - family']]) -configFrom(path.join(ROOT, 'src/main/resources/config.yml'), path.join(dir, 'plugins/Mapkeeper/config.yml'), [ +configFrom(path.join(ROOT, 'src/main/resources/config.yml'), path.join(dir, 'plugins/BlueMapAuth/config.yml'), [ ['enabled: false', 'enabled: true'], ['port: 8180', 'port: ' + MAP_WEB], ['public-url: ""', 'public-url: "' + MAP + '"'], ['bluemap-url: "http://127.0.0.1:8100"', 'bluemap-url: "http://127.0.0.1:' + BLUEMAP + '"'], ['sign-in-url: ""', 'sign-in-url: "' + PLAY + '"'], ['world-permission: "multiverse.access.{world}"', 'world-permission: "mktest.world.{world}"'], @@ -210,10 +210,10 @@ async function missingPieces() { const seen = playersIn((await adult.map.req('/maps/world/live/players.json')).body) check('but sees only themselves: no HouseRules to say who they may reach', seen?.length === 1 && seen[0] === ADULT, JSON.stringify(seen)) const status = log.length - send('mapkeeper status') + send('bluemapauth status') await sleep(800) const said = log.slice(status).join('\n') - check('/mapkeeper status names what\'s missing and what that means', /LuckPerms: missing, so someone who isn't in game sees no maps/.test(said) + check('/bluemapauth status names what\'s missing and what that means', /LuckPerms: missing, so someone who isn't in game sees no maps/.test(said) && /HouseRules: missing, so the map shows nobody but the viewer themselves/.test(said)) } @@ -238,10 +238,10 @@ try { await sleep(1000) } check('BlueMap lists the three dimensions\' maps', blueMaps?.length >= 3, JSON.stringify(blueMaps)) - send('mapkeeper reload') + send('bluemapauth reload') await waitFor(/Serving the map on 127\.0\.0\.1:\d+ .* [1-9]\d* map\(s\) known/, 20000, log.length - 1).catch(() => {}) const serving = log.filter(l => /Serving the map/.test(l)).pop() ?? '' - check('Mapkeeper serves the map, bound to this machine, and knows BlueMap\'s maps', /127\.0\.0\.1:25694 .* [3-9] map\(s\) known/.test(serving), serving.replace(/^.*Serving/, 'Serving')) + check('BlueMapAuth serves the map, bound to this machine, and knows BlueMap\'s maps', /127\.0\.0\.1:25694 .* [3-9] map\(s\) known/.test(serving), serving.replace(/^.*Serving/, 'Serving')) for (const n of ['Kid', 'Mum', 'Adult', 'Guest']) send('whitelist add ' + n) if (MISSING) { await missingPieces(); throw 'done' } @@ -340,11 +340,11 @@ try { } finally { for (const n of Object.keys(bots)) bots[n].quit() if (proc && proc.exitCode === null) await stop().catch(() => proc.kill('SIGKILL')) - const problems = log.filter(l => /Mapkeeper|mapkeeper/.test(l) && /WARN|ERROR|SEVERE|Exception/.test(l)) - if (problems.length) console.log('Mapkeeper log lines worth a look:\n ' + problems.slice(0, 10).join('\n ')) - writeFileSync(path.join(RUN, 'mapkeeper-server.log'), log.join('\n') + '\n') + const problems = log.filter(l => /BlueMapAuth|bluemapauth/.test(l) && /WARN|ERROR|SEVERE|Exception/.test(l)) + if (problems.length) console.log('BlueMapAuth log lines worth a look:\n ' + problems.slice(0, 10).join('\n ')) + writeFileSync(path.join(RUN, 'bluemapauth-server.log'), log.join('\n') + '\n') rmSync(dir, { recursive: true, force: true }) } const failed = results.filter(r => !r.ok).length -console.log(`SUMMARY ${results.length - failed}/${results.length} passed${crashed ? ', CRASHED' : ''}. Server deleted; log in ${path.join(RUN, 'mapkeeper-server.log')}`) +console.log(`SUMMARY ${results.length - failed}/${results.length} passed${crashed ? ', CRASHED' : ''}. Server deleted; log in ${path.join(RUN, 'bluemapauth-server.log')}`) process.exit(failed || crashed ? 1 : 0) diff --git a/test/live/package.json b/test/live/package.json index 4d34b76..bdedc7c 100644 --- a/test/live/package.json +++ b/test/live/package.json @@ -1 +1 @@ -{ "name": "mapkeeper-tests", "private": true, "type": "module", "dependencies": { "mineflayer": "^4.39.0" } } +{ "name": "bluemapauth-tests", "private": true, "type": "module", "dependencies": { "mineflayer": "^4.39.0" } } From 8dd1d3aa0d64cc5a2dd6786e0e6dd86de9925336 Mon Sep 17 00:00:00 2001 From: Michael Gilardi <11632652+mgilardi@users.noreply.github.com> Date: Sat, 14 Nov 2026 11:26:08 -0700 Subject: [PATCH 2/3] Drop every trace of the old name The owner asked that no old names be kept: no alias, old permission, folder copy or upgrade section. The release notes say how a server installs 0.2.0. Co-Authored-By: Claude Opus 5.5 --- README.md | 11 +---- docs/decisions.md | 2 +- docs/releases/v0.2.0.md | 16 ++++--- docs/test-audit.md | 6 +-- .../bluemapauth/BlueMapAuthPlugin.java | 5 +- .../com/extantape/bluemapauth/Migration.java | 48 ------------------- src/main/resources/paper-plugin.yml | 5 -- .../com/extantape/bluemapauth/SetupTest.java | 2 +- test/live/bluemapauth.mjs | 2 +- test/live/package-lock.json | 4 +- 10 files changed, 19 insertions(+), 82 deletions(-) delete mode 100644 src/main/java/com/extantape/bluemapauth/Migration.java diff --git a/README.md b/README.md index c6b4f7d..9ebaeb7 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ BlueMapAuth for Paper: BlueMap's web map behind a sign-in, showing each player only the worlds and players they're allowed to see. -**Status:** early, version 0.2.0, renamed from Mapkeeper (D194; see below). 24 HTTP and config tests pass, plus a bot test (25/25, and 8/8 without HouseRules and LuckPerms, 2026-11-11) on a throwaway Paper 26.1.2 server with the real BlueMap 5.29, LuckPerms 5.5, HouseRules and Latchkey, signing in through Latchkey's "Open the map" over HTTP. The hand-off page was checked in a real browser (Chromium, 2026-11-11, against made-up data on localhost; `BrowserDemo` in the test sources). The token leaves the address bar, the cookie is invisible to scripts, a reused link explains itself, and the page has no policy errors. On a copy of a real server on Paper 26.2 and 26.3 build 249 (2026-11-14) it loaded with no errors, switched off, so serving the map on 26.2 and 26.3 is still untested, as is running behind Caddy. +**Status:** early, version 0.2.0. 24 HTTP and config tests pass, plus a bot test (25/25, and 8/8 without HouseRules and LuckPerms, 2026-11-11) on a throwaway Paper 26.1.2 server with the real BlueMap 5.29, LuckPerms 5.5, HouseRules and Latchkey, signing in through Latchkey's "Open the map" over HTTP. The hand-off page was checked in a real browser (Chromium, 2026-11-11, against made-up data on localhost; `BrowserDemo` in the test sources). The token leaves the address bar, the cookie is invisible to scripts, a reused link explains itself, and the page has no policy errors. On a copy of a real server on Paper 26.2 and 26.3 build 249 (2026-11-14) it loaded with no errors, switched off, so serving the map on 26.2 and 26.3 is still untested, as is running behind Caddy. ## What it does @@ -31,15 +31,6 @@ The jar is `build/libs/BlueMapAuth-.jar`. In `plugins/BlueMapAuth/confi - `/bluemapauth status`: whether the map is served, what's wrong with the config, and which plugins it found. Needs `bluemapauth.admin`. - `/bluemapauth reload`: re-reads `config.yml`. -## Upgrading from Mapkeeper - -BlueMapAuth was called Mapkeeper up to 0.1.0, and renamed so people looking for BlueMap add-ons find it. Nothing else changed in how it works. - -- With the server stopped, swap `Mapkeeper-0.1.0.jar` for `BlueMapAuth-0.2.0.jar`. -- On its first start, BlueMapAuth copies `plugins/Mapkeeper/` to `plugins/BlueMapAuth/` if that doesn't exist yet. The old folder is left as it was. -- For 0.2.x only, `/mapkeeper` still works and `mapkeeper.admin` still grants `bluemapauth.admin`. Both go in the next release. -- Map sessions start again: the map's cookie has a new name, so anyone signed in to the map signs in once more through Latchkey. - ## License MIT. See [LICENSE](LICENSE). diff --git a/docs/decisions.md b/docs/decisions.md index 4e3c831..6cc5a08 100644 --- a/docs/decisions.md +++ b/docs/decisions.md @@ -14,4 +14,4 @@ Dated decisions for this repo, newest last. ## 2026-11-14 -- **Name (owner, D194):** Mapkeeper is renamed BlueMapAuth, so people looking for BlueMap add-ons find it. The owner: "yes… BlueMapAuth". Released as 0.2.0, with the old folder copied on first start and `/mapkeeper` and `mapkeeper.admin` working for 0.2.x. +- **Name (owner, D194):** Mapkeeper is renamed BlueMapAuth, so people looking for BlueMap add-ons find it. The owner: "yes… BlueMapAuth". Released as 0.2.0. The owner asked that no old names be kept, so there's no alias, old permission or folder copy. diff --git a/docs/releases/v0.2.0.md b/docs/releases/v0.2.0.md index da16f3f..98dbb56 100644 --- a/docs/releases/v0.2.0.md +++ b/docs/releases/v0.2.0.md @@ -1,12 +1,14 @@ -Mapkeeper is now BlueMapAuth (D194), so people looking for BlueMap add-ons find it. Nothing else changed in how it works. +A new name (D194), so people looking for BlueMap add-ons find it. Nothing else changed in how it works. -## Upgrading +## Installing over the previous version -- Swap `Mapkeeper-0.1.0.jar` for `BlueMapAuth-0.2.0.jar` with the server stopped. -- On first start, BlueMapAuth copies `plugins/Mapkeeper/` to `plugins/BlueMapAuth/` if that doesn't exist yet. The old folder stays as it was. -- For 0.2.x only, `/mapkeeper` still works and `mapkeeper.admin` still grants `bluemapauth.admin`. -- The map's cookie has a new name, so anyone signed in to the map signs in once more through Latchkey. +With the server stopped: +1. Rename its plugin folder to `plugins/BlueMapAuth`. +2. Grant `bluemapauth.admin` in place of its old permission. +3. Swap in `BlueMapAuth-0.2.0.jar`. + +Anyone signed in to the map signs in once more through Latchkey, because the map's cookie has a new name. ## Tested -Unit and HTTP tests pass. The carry-over was checked on a throwaway server. +Unit and HTTP tests pass. diff --git a/docs/test-audit.md b/docs/test-audit.md index bd290ae..bfa4ec7 100644 --- a/docs/test-audit.md +++ b/docs/test-audit.md @@ -15,7 +15,7 @@ Kept by this repo's owning session, per `~/Code/CLAUDE.md`, "Test self-audits". | --- | --- | | Nothing of the map for a visitor who isn't signed in, and BlueMap is never asked | `aVisitorWhoIsntSignedInGetsNothingOfTheMap` | | Hand-off: once, host-only Strict cookie, only from the map's own origin, rate limited | `aHandOffSetsAHostOnlyStrictCookieOnce`, `handOffsFromElsewhereOrMalformedAreRefused`, `handOffTriesAreRateLimited` | -| The token leaves the address bar; strict CSP on Mapkeeper's own pages | `theHandOffPageMovesTheTokenOutOfTheAddressBarUnderAStrictPolicy` | +| The token leaves the address bar; strict CSP on BlueMapAuth's own pages | `theHandOffPageMovesTheTokenOutOfTheAddressBarUnderAStrictPolicy` | | A kid away from the game sees only their worlds' maps and their circle (D54) | `anAwayKidSeesOnlyTheirWorldsMapsAndTheirCircle` | | A world the viewer can't enter: list entry, tiles, markers and players all absent, with the same 404 as a missing map | `anAdultWorldsMapIsNotThereForAKidAtAll` | | In game, chat's reach decides (D41) | `anAdultSeesBothWorldsAndThePlayersTheyMayReach` (the reach rules themselves are HouseRules' tests) | @@ -26,7 +26,7 @@ Kept by this repo's owning session, per `~/Code/CLAUDE.md`, "Test self-audits". | Unsafe config never starts: bind, BlueMap address, URLs, proxies, permission, limits | `SetupTest` (8 tests) | Gaps, with why: -- **LiveAccess** (the calls into Latchkey, HouseRules, BlueMap and LuckPerms) is covered by the bot test, `test/live/mapkeeper.mjs`, 25/25 on 2026-11-11 with real plugins. It covers: +- **LiveAccess** (the calls into Latchkey, HouseRules, BlueMap and LuckPerms) is covered by the bot test, `test/live/bluemapauth.mjs`, 25/25 on 2026-11-11 with real plugins. It covers: - an away kid sees only their circle (D54), and in game, chat's reach (D41); - an adults-only world's map is absent for a kid; - losing a circle or a world reaches the map within 30 seconds; @@ -35,7 +35,7 @@ Gaps, with why: The fail-closed paths have their own run, `MK_TEST_MISSING=1`, which passed 8/8 on 2026-11-11 without HouseRules or LuckPerms: - an away viewer gets no maps and no players; - an operator in game sees only themselves; - - `/mapkeeper status` names what's missing. + - `/bluemapauth status` names what's missing. Without Latchkey there's no way to make a hand-off token, and a made-up one is refused (`handOffsFromElsewhereOrMalformedAreRefused`). - The hand-off page's script ran in a real browser on 2026-11-11 (`BrowserDemo`, made-up data). It signed in and landed on the map, the token left the address bar, the cookie wasn't readable by scripts, `settings.json` listed only the allowed map, the other map was 404, a reused link showed its message in a `role=status` line, and the console showed no policy errors. This was a manual check, not automated. diff --git a/src/main/java/com/extantape/bluemapauth/BlueMapAuthPlugin.java b/src/main/java/com/extantape/bluemapauth/BlueMapAuthPlugin.java index 9b01efc..b0f79bd 100644 --- a/src/main/java/com/extantape/bluemapauth/BlueMapAuthPlugin.java +++ b/src/main/java/com/extantape/bluemapauth/BlueMapAuthPlugin.java @@ -28,13 +28,10 @@ public final class BlueMapAuthPlugin extends JavaPlugin { @Override public void onEnable() { - // Renamed from Mapkeeper (D194): bring its folder across once, before anything reads the config. - String moved = Migration.copyIfMissing(getDataFolder().toPath().resolveSibling("Mapkeeper"), getDataFolder().toPath()); - if (moved != null) getLogger().warning(moved); saveDefaultConfig(); start(); getLifecycleManager().registerEventHandler(LifecycleEvents.COMMANDS, e -> e.registrar().register("bluemapauth", - "BlueMapAuth's status, and reloading its settings.", List.of("mapkeeper") /* the old name, for 0.2.x only */, new BasicCommand() { + "BlueMapAuth's status, and reloading its settings.", List.of(), new BasicCommand() { @Override public void execute(CommandSourceStack source, String[] args) { command(source.getSender(), args); diff --git a/src/main/java/com/extantape/bluemapauth/Migration.java b/src/main/java/com/extantape/bluemapauth/Migration.java deleted file mode 100644 index 58d7152..0000000 --- a/src/main/java/com/extantape/bluemapauth/Migration.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.extantape.bluemapauth; - -import java.io.IOException; -import java.io.UncheckedIOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.StandardCopyOption; -import java.util.stream.Stream; - -/** Carries a server's files over from the old plugin folder after the rename from Mapkeeper (D194, 2026-11-14). */ -final class Migration { - private Migration() {} - - /** - * Copies {@code old} to {@code now} if {@code now} doesn't exist and {@code old} is a folder. Copies into a - * temporary sibling first and renames it into place, so a crash halfway leaves no half-filled folder. - * - * @return a line for the log saying what happened, or null if there was nothing to do - */ - static String copyIfMissing(Path old, Path now) { - if (Files.exists(now) || !Files.isDirectory(old)) return null; - Path tmp = now.resolveSibling(now.getFileName() + ".migrating"); - try { - if (Files.exists(tmp)) deleteTree(tmp); - try (Stream all = Files.walk(old)) { - all.forEach(p -> { - Path to = tmp.resolve(old.relativize(p).toString()); - try { - if (Files.isDirectory(p)) Files.createDirectories(to); - else Files.copy(p, to, StandardCopyOption.COPY_ATTRIBUTES); - } catch (IOException e) { throw new UncheckedIOException(e); } - }); - } - Files.move(tmp, now, StandardCopyOption.ATOMIC_MOVE); - return "Copied plugins/" + old.getFileName() + " to plugins/" + now.getFileName() - + " (Mapkeeper is now called BlueMapAuth). The old folder was left untouched; delete it once you're happy."; - } catch (IOException | UncheckedIOException e) { - return "Couldn't copy plugins/" + old.getFileName() + " to plugins/" + now.getFileName() + ": " + e.getMessage() - + ". Copy it by hand while the server is stopped, or BlueMapAuth starts with a fresh config."; - } - } - - private static void deleteTree(Path root) throws IOException { - try (Stream all = Files.walk(root)) { - for (Path p : all.sorted(java.util.Comparator.reverseOrder()).toList()) Files.delete(p); - } - } -} diff --git a/src/main/resources/paper-plugin.yml b/src/main/resources/paper-plugin.yml index 94ba629..9b4422f 100644 --- a/src/main/resources/paper-plugin.yml +++ b/src/main/resources/paper-plugin.yml @@ -27,8 +27,3 @@ permissions: bluemapauth.admin: description: Use /bluemapauth status and reload. default: op - mapkeeper.admin: - description: The old name for bluemapauth.admin, from before the rename (D194). It grants bluemapauth.admin, still works in 0.2.x, and is removed in the next release. - default: false - children: - bluemapauth.admin: true diff --git a/src/test/java/com/extantape/bluemapauth/SetupTest.java b/src/test/java/com/extantape/bluemapauth/SetupTest.java index d247c7b..cdafd64 100644 --- a/src/test/java/com/extantape/bluemapauth/SetupTest.java +++ b/src/test/java/com/extantape/bluemapauth/SetupTest.java @@ -36,7 +36,7 @@ void aGoodConfigStarts() { } @Test - void mapkeeperNeverListensBeyondThisMachine() { + void neverListensBeyondThisMachine() { for (String bind : new String[]{"0.0.0.0", "::", "192.168.1.5", "example.org"}) assertFalse(read(GOOD + "bind: '" + bind + "'\n").ok(), bind); } diff --git a/test/live/bluemapauth.mjs b/test/live/bluemapauth.mjs index cbf5d25..263e4da 100644 --- a/test/live/bluemapauth.mjs +++ b/test/live/bluemapauth.mjs @@ -268,7 +268,7 @@ try { // --- 2. an away kid: the hand-off, then only their world and their circle (D54) --- const kid = await openMap(KID, 'Kid') check('the hand-off signs the kid\'s browser in to the map', kid.status === 204, String(kid.status)) - check('with a host-only, HttpOnly, Secure, Strict cookie', /^mapkeeper=/.test(kid.setCookie) && /HttpOnly/.test(kid.setCookie) + check('with a host-only, HttpOnly, Secure, Strict cookie', /^bluemapauth=/.test(kid.setCookie) && /HttpOnly/.test(kid.setCookie) && /Secure/.test(kid.setCookie) && /SameSite=Strict/.test(kid.setCookie) && !/domain=/i.test(kid.setCookie), kid.setCookie.replace(/=[^;]+/, '=…')) const again = await new Browser(MAP_WEB).req('/handoff', { method: 'POST', body: 'token=' + kid.token, headers: { origin: MAP, 'content-type': 'application/x-www-form-urlencoded' } }) check('the same hand-off link doesn\'t work twice', again.status === 403, String(again.status)) diff --git a/test/live/package-lock.json b/test/live/package-lock.json index 805dd4a..0d3138d 100644 --- a/test/live/package-lock.json +++ b/test/live/package-lock.json @@ -1,10 +1,10 @@ { - "name": "mapkeeper-tests", + "name": "bluemapauth-tests", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "mapkeeper-tests", + "name": "bluemapauth-tests", "dependencies": { "mineflayer": "^4.39.0" } From a2fdcc3af9a7042b5bcbe59691f85e8ab9d4ef73 Mon Sep 17 00:00:00 2001 From: Michael Gilardi <11632652+mgilardi@users.noreply.github.com> Date: Sat, 14 Nov 2026 12:38:46 -0700 Subject: [PATCH 3/3] Call WelcomeWagon and Mayor by their new names D197 and D198 renamed the sign-in and chat-rules plugins. BlueMapAuth reaches both by name, so its lookups, docs, test harness and env vars follow. With either missing it still fails closed, as before: no sign-ins without WelcomeWagon, and only yourself on the map without Mayor. Co-Authored-By: Claude Opus 5.5 --- README.md | 14 ++--- docs/design.md | 20 +++---- docs/releases/v0.2.0.md | 2 +- docs/test-audit.md | 12 ++--- .../bluemapauth/BlueMapAuthPlugin.java | 4 +- .../extantape/bluemapauth/access/Access.java | 6 +-- .../bluemapauth/access/LiveAccess.java | 16 +++--- .../extantape/bluemapauth/web/Sessions.java | 10 ++-- src/main/resources/config.yml | 2 +- src/main/resources/paper-plugin.yml | 4 +- .../bluemapauth/web/MapServerTest.java | 6 +-- test/live/bluemapauth.mjs | 54 +++++++++---------- 12 files changed, 75 insertions(+), 75 deletions(-) diff --git a/README.md b/README.md index 9ebaeb7..9d3b2c5 100644 --- a/README.md +++ b/README.md @@ -2,29 +2,29 @@ BlueMapAuth for Paper: BlueMap's web map behind a sign-in, showing each player only the worlds and players they're allowed to see. -**Status:** early, version 0.2.0. 24 HTTP and config tests pass, plus a bot test (25/25, and 8/8 without HouseRules and LuckPerms, 2026-11-11) on a throwaway Paper 26.1.2 server with the real BlueMap 5.29, LuckPerms 5.5, HouseRules and Latchkey, signing in through Latchkey's "Open the map" over HTTP. The hand-off page was checked in a real browser (Chromium, 2026-11-11, against made-up data on localhost; `BrowserDemo` in the test sources). The token leaves the address bar, the cookie is invisible to scripts, a reused link explains itself, and the page has no policy errors. On a copy of a real server on Paper 26.2 and 26.3 build 249 (2026-11-14) it loaded with no errors, switched off, so serving the map on 26.2 and 26.3 is still untested, as is running behind Caddy. +**Status:** early, version 0.2.0. 24 HTTP and config tests pass, plus a bot test (25/25, and 8/8 without Mayor and LuckPerms, 2026-11-11) on a throwaway Paper 26.1.2 server with the real BlueMap 5.29, LuckPerms 5.5, Mayor and WelcomeWagon, signing in through WelcomeWagon's "Open the map" over HTTP. The hand-off page was checked in a real browser (Chromium, 2026-11-11, against made-up data on localhost; `BrowserDemo` in the test sources). The token leaves the address bar, the cookie is invisible to scripts, a reused link explains itself, and the page has no policy errors. On a copy of a real server on Paper 26.2 and 26.3 build 249 (2026-11-14) it loaded with no errors, switched off, so serving the map on 26.2 and 26.3 is still untested, as is running behind Caddy. ## What it does - Serves BlueMap's web map at its own address, such as `map.example.org`, and nothing of it to anyone who isn't signed in. BlueMap's own web server stays on 127.0.0.1, so BlueMapAuth is the only way in. -- Signs a browser in with a one-time link from Latchkey's invite page ("Open the map"). The link works once, for a minute. The map then has its own cookie for its own address only, and it ends within 30 seconds of the Latchkey session ending. +- Signs a browser in with a one-time link from WelcomeWagon's invite page ("Open the map"). The link works once, for a minute. The map then has its own cookie for its own address only, and it ends within 30 seconds of the WelcomeWagon session ending. - Lists only the maps of worlds the viewer may enter (`multiverse.access.` by default). Any other map is "not found", the same as one that doesn't exist. -- Shows only the players the viewer may see. In game, that's chat's reach from HouseRules. A viewer who isn't in game sees only players who share a HouseRules circle with them. -- Fails closed. Without Latchkey nobody can sign in. Without BlueMap there are no maps. Without HouseRules the viewer sees only themselves. For a viewer who isn't in game, without LuckPerms there are no maps and no other players. +- Shows only the players the viewer may see. In game, that's chat's reach from Mayor. A viewer who isn't in game sees only players who share a Mayor circle with them. +- Fails closed. Without WelcomeWagon nobody can sign in. Without BlueMap there are no maps. Without Mayor the viewer sees only themselves. For a viewer who isn't in game, without LuckPerms there are no maps and no other players. ## Install or build -Needs Paper 26.1 or newer and Java 25. BlueMap, LuckPerms, HouseRules (0.4 or newer, for circles while away) and Latchkey (0.4 or newer, for the hand-off) are all optional. +Needs Paper 26.1 or newer and Java 25. BlueMap, LuckPerms, Mayor (0.4 or newer, for circles while away) and WelcomeWagon (0.4 or newer, for the hand-off) are all optional. ``` ./gradlew build ``` -The jar is `build/libs/BlueMapAuth-.jar`. In `plugins/BlueMapAuth/config.yml`, set `enabled: true` and `public-url`. Point your HTTPS proxy at `127.0.0.1:8180`, and set BlueMap's web server to `ip: "127.0.0.1"`. In Latchkey, set `page.map-address` to the same address. +The jar is `build/libs/BlueMapAuth-.jar`. In `plugins/BlueMapAuth/config.yml`, set `enabled: true` and `public-url`. Point your HTTPS proxy at `127.0.0.1:8180`, and set BlueMap's web server to `ip: "127.0.0.1"`. In WelcomeWagon, set `page.map-address` to the same address. ## Bot test -`test/live/bluemapauth.mjs` builds a throwaway server in a temp folder, runs bots and browser requests against it, and deletes it. The settings it needs are at the top of the file. `MK_TEST_MISSING=1` runs it without HouseRules and LuckPerms, to check those paths fail closed. It needs Node 22 or newer, and `npm ci` in `test/live` first. +`test/live/bluemapauth.mjs` builds a throwaway server in a temp folder, runs bots and browser requests against it, and deletes it. The settings it needs are at the top of the file. `MK_TEST_MISSING=1` runs it without Mayor and LuckPerms, to check those paths fail closed. It needs Node 22 or newer, and `npm ci` in `test/live` first. ## Commands diff --git a/docs/design.md b/docs/design.md index 4514f4b..71006ee 100644 --- a/docs/design.md +++ b/docs/design.md @@ -7,21 +7,21 @@ BlueMapAuth puts BlueMap's web map behind a sign-in and shows each signed-in pla ``` browser ──https──▶ Caddy (map.) ──▶ BlueMapAuth (127.0.0.1:8180) ──▶ BlueMap's web server (127.0.0.1:8100) │ in-process, by name: - ├─ Latchkey: hand-off tokens, session still valid? + ├─ WelcomeWagon: hand-off tokens, session still valid? ├─ BlueMap API: which world each map shows ├─ LuckPerms: may this player enter that world? (offline too) - └─ HouseRules: may the viewer reach that player? + └─ Mayor: may the viewer reach that player? ``` - **BlueMapAuth is the only way in.** BlueMap's own web server listens on 127.0.0.1 only. BlueMapAuth also listens on 127.0.0.1 only, behind the same Caddy as the invite page. -- **No hard dependencies** (D2). Latchkey, LuckPerms and HouseRules are each read by name. Without one, the part that needs it fails closed: no Latchkey means nobody can sign in; no permissions check means no maps; no HouseRules means no other players on the map. +- **No hard dependencies** (D2). WelcomeWagon, LuckPerms and Mayor are each read by name. Without one, the part that needs it fails closed: no WelcomeWagon means nobody can sign in; no permissions check means no maps; no Mayor means no other players on the map. ## Signing in (D43) 1. On the invite page's welcome view, a signed-in player clicks **Open the map**. -2. Latchkey makes a one-time token for that player and that session: random, single use, good for 60 seconds, audience `map`. It redirects to `https://map./handoff#` (after `#`, so it never reaches a log). -3. The page posts the token to BlueMapAuth, which asks Latchkey to redeem it (in-process). Latchkey answers with the player and the session it came from, once. -4. BlueMapAuth sets its own cookie on `map.` only: HttpOnly, Secure, SameSite=Strict, no Domain attribute. It lasts no longer than the Latchkey session, and ends when that session ends: BlueMapAuth asks Latchkey whether it's still valid (cached for 30 seconds), so a sign-out, a revoke or a whitelist removal reaches the map within 30 seconds. +2. WelcomeWagon makes a one-time token for that player and that session: random, single use, good for 60 seconds, audience `map`. It redirects to `https://map./handoff#` (after `#`, so it never reaches a log). +3. The page posts the token to BlueMapAuth, which asks WelcomeWagon to redeem it (in-process). WelcomeWagon answers with the player and the session it came from, once. +4. BlueMapAuth sets its own cookie on `map.` only: HttpOnly, Secure, SameSite=Strict, no Domain attribute. It lasts no longer than the WelcomeWagon session, and ends when that session ends: BlueMapAuth asks WelcomeWagon whether it's still valid (cached for 30 seconds), so a sign-out, a revoke or a whitelist removal reaches the map within 30 seconds. ## What each viewer gets @@ -34,17 +34,17 @@ browser ──https──▶ Caddy (map.) ──▶ BlueMapAuth (127.0.0 | the web app (`/`, `/assets/...`, `/lang/...`) | passed through | the sign-in page instead of the app | - **Which worlds:** the same permission the server uses, `multiverse.access.`, read through LuckPerms so it works while the player is offline. Can't read it: no map. -- **Which players:** with the viewer online in game, HouseRules' `mayReach(viewer, target)`, exactly chat's rule. With the viewer not in game (D54): only players who share a HouseRules circle with them. If HouseRules can't answer, nobody. +- **Which players:** with the viewer online in game, Mayor' `mayReach(viewer, target)`, exactly chat's rule. With the viewer not in game (D54): only players who share a Mayor circle with them. If Mayor can't answer, nobody. - Every answer carries `Cache-Control: private, no-store` for live data, the same security headers as the invite page, and no CORS. ## Changes in other plugins -- **Latchkey:** a hand-off service (make a token for the welcome view's link, redeem it once, say whether a session is still valid) and the "Open the map" link, shown only when a map address is set. -- **HouseRules:** `sharesCircle(UUID viewer, UUID target)` for a viewer who isn't in game (D54), by circles only. +- **WelcomeWagon:** a hand-off service (make a token for the welcome view's link, redeem it once, say whether a session is still valid) and the "Open the map" link, shown only when a map address is set. +- **Mayor:** `sharesCircle(UUID viewer, UUID target)` for a viewer who isn't in game (D54), by circles only. ## Tests -Bots and HTTP, on throwaway servers with BlueMap, LuckPerms, HouseRules and Latchkey: +Bots and HTTP, on throwaway servers with BlueMap, LuckPerms, Mayor and WelcomeWagon: - an unsigned visitor gets nothing: not the map list, not a tile, not players.json; - a kid account never receives an adult world's map list entry, tiles or markers, and never an adult player in players.json; diff --git a/docs/releases/v0.2.0.md b/docs/releases/v0.2.0.md index 98dbb56..ee74499 100644 --- a/docs/releases/v0.2.0.md +++ b/docs/releases/v0.2.0.md @@ -11,4 +11,4 @@ Anyone signed in to the map signs in once more through Latchkey, because the map ## Tested -Unit and HTTP tests pass. +Unit and HTTP tests pass. It finds WelcomeWagon and Mayor by their new names, so install it together with WelcomeWagon 0.6.0 and Mayor 0.5.0. diff --git a/docs/test-audit.md b/docs/test-audit.md index bfa4ec7..60c1251 100644 --- a/docs/test-audit.md +++ b/docs/test-audit.md @@ -18,24 +18,24 @@ Kept by this repo's owning session, per `~/Code/CLAUDE.md`, "Test self-audits". | The token leaves the address bar; strict CSP on BlueMapAuth's own pages | `theHandOffPageMovesTheTokenOutOfTheAddressBarUnderAStrictPolicy` | | A kid away from the game sees only their worlds' maps and their circle (D54) | `anAwayKidSeesOnlyTheirWorldsMapsAndTheirCircle` | | A world the viewer can't enter: list entry, tiles, markers and players all absent, with the same 404 as a missing map | `anAdultWorldsMapIsNotThereForAKidAtAll` | -| In game, chat's reach decides (D41) | `anAdultSeesBothWorldsAndThePlayersTheyMayReach` (the reach rules themselves are HouseRules' tests) | +| In game, chat's reach decides (D41) | `anAdultSeesBothWorldsAndThePlayersTheyMayReach` (the reach rules themselves are Mayor' tests) | | Odd BlueMap data shows nobody; a broken BlueMap shows an empty error | `oddPlayerListsShowNobody`, `aBrokenBlueMapGivesAnEmptyErrorWithNoDetails` | -| Map access ends within 30 s of Latchkey's session, and after a day at most | `signingOutOfLatchkeyEndsTheMapWithin30Seconds`, `aMapSessionLastsADayAtMost` | +| Map access ends within 30 s of WelcomeWagon's session, and after a day at most | `signingOutOfWelcomeWagonEndsTheMapWithin30Seconds`, `aMapSessionLastsADayAtMost` | | Cookies and auth headers never reach BlueMap; its headers don't come back | `cookiesAndOtherHeadersNeverReachBlueMapAndItsHeadersDontComeBack` | | Odd paths and methods refused; planted duplicate cookies count as none | `oddPathsAndMethodsAreRefused`, `twoMapCookiesCountAsNone`, `aMadeUpOrForeignCookieIsNoSession` | | Unsafe config never starts: bind, BlueMap address, URLs, proxies, permission, limits | `SetupTest` (8 tests) | Gaps, with why: -- **LiveAccess** (the calls into Latchkey, HouseRules, BlueMap and LuckPerms) is covered by the bot test, `test/live/bluemapauth.mjs`, 25/25 on 2026-11-11 with real plugins. It covers: +- **LiveAccess** (the calls into WelcomeWagon, Mayor, BlueMap and LuckPerms) is covered by the bot test, `test/live/bluemapauth.mjs`, 25/25 on 2026-11-11 with real plugins. It covers: - an away kid sees only their circle (D54), and in game, chat's reach (D41); - an adults-only world's map is absent for a kid; - losing a circle or a world reaches the map within 30 seconds; - - signing out of Latchkey, or removal from the whitelist, ends map access within 30 seconds. + - signing out of WelcomeWagon, or removal from the whitelist, ends map access within 30 seconds. - The fail-closed paths have their own run, `MK_TEST_MISSING=1`, which passed 8/8 on 2026-11-11 without HouseRules or LuckPerms: + The fail-closed paths have their own run, `MK_TEST_MISSING=1`, which passed 8/8 on 2026-11-11 without Mayor or LuckPerms: - an away viewer gets no maps and no players; - an operator in game sees only themselves; - `/bluemapauth status` names what's missing. - Without Latchkey there's no way to make a hand-off token, and a made-up one is refused (`handOffsFromElsewhereOrMalformedAreRefused`). + Without WelcomeWagon there's no way to make a hand-off token, and a made-up one is refused (`handOffsFromElsewhereOrMalformedAreRefused`). - The hand-off page's script ran in a real browser on 2026-11-11 (`BrowserDemo`, made-up data). It signed in and landed on the map, the token left the address bar, the cookie wasn't readable by scripts, `settings.json` listed only the allowed map, the other map was 404, a reused link showed its message in a `role=status` line, and the console showed no policy errors. This was a manual check, not automated. diff --git a/src/main/java/com/extantape/bluemapauth/BlueMapAuthPlugin.java b/src/main/java/com/extantape/bluemapauth/BlueMapAuthPlugin.java index b0f79bd..24481eb 100644 --- a/src/main/java/com/extantape/bluemapauth/BlueMapAuthPlugin.java +++ b/src/main/java/com/extantape/bluemapauth/BlueMapAuthPlugin.java @@ -90,7 +90,7 @@ private void command(CommandSender to, String[] args) { to.sendMessage(Component.text(server != null ? "Serving the map on port " + server.port() + ", " + access.mapWorlds().size() + " map(s) known." : "Not serving the map.", server != null ? NamedTextColor.GREEN : NamedTextColor.YELLOW)); for (String p : problems) to.sendMessage(Component.text("- " + p, NamedTextColor.RED)); - for (String name : List.of("Latchkey", "BlueMap", "LuckPerms", "HouseRules")) { + for (String name : List.of("WelcomeWagon", "BlueMap", "LuckPerms", "Mayor")) { boolean on = getServer().getPluginManager().isPluginEnabled(name); to.sendMessage(Component.text(name + ": " + (on ? "found" : "missing, so " + missing(name)), on ? NamedTextColor.WHITE : NamedTextColor.RED)); } @@ -101,7 +101,7 @@ private void command(CommandSender to, String[] args) { private static String missing(String plugin) { return switch (plugin) { - case "Latchkey" -> "nobody can sign in to the map"; + case "WelcomeWagon" -> "nobody can sign in to the map"; case "BlueMap" -> "there are no maps to show"; case "LuckPerms" -> "someone who isn't in game sees no maps and no other players"; default -> "the map shows nobody but the viewer themselves"; diff --git a/src/main/java/com/extantape/bluemapauth/access/Access.java b/src/main/java/com/extantape/bluemapauth/access/Access.java index 73c66d2..f1b21dd 100644 --- a/src/main/java/com/extantape/bluemapauth/access/Access.java +++ b/src/main/java/com/extantape/bluemapauth/access/Access.java @@ -10,13 +10,13 @@ * Every method must be safe from any thread, and must answer "no" (empty, false, nothing) when it can't be sure. */ public interface Access { - /** Who a browser was handed over for. {@code session} is Latchkey's opaque reference. */ + /** Who a browser was handed over for. {@code session} is WelcomeWagon's opaque reference. */ record Viewer(UUID uuid, String name, String session) {} - /** Redeems a one-time hand-off token from Latchkey. Empty for anything not fresh, unused and live. */ + /** Redeems a one-time hand-off token from WelcomeWagon. Empty for anything not fresh, unused and live. */ Optional redeem(String token); - /** Whether the Latchkey session behind a viewer is still live. */ + /** Whether the WelcomeWagon session behind a viewer is still live. */ boolean live(String session); /** BlueMap map ids to the world each one shows. Maps whose world isn't known are left out. */ diff --git a/src/main/java/com/extantape/bluemapauth/access/LiveAccess.java b/src/main/java/com/extantape/bluemapauth/access/LiveAccess.java index e424f80..a5ec632 100644 --- a/src/main/java/com/extantape/bluemapauth/access/LiveAccess.java +++ b/src/main/java/com/extantape/bluemapauth/access/LiveAccess.java @@ -16,14 +16,14 @@ import java.util.logging.Logger; /** - * The real answers, from the plugins on the server. Latchkey and HouseRules are called by method name with plain Java + * The real answers, from the plugins on the server. WelcomeWagon and Mayor are called by method name with plain Java * and Bukkit types, so BlueMapAuth builds without them (D40). BlueMap and LuckPerms are used only when installed. Each * missing piece answers "no" (docs/design.md): *
      - *
    • no Latchkey: nobody can sign in, and every map session ends at its next check;
    • + *
    • no WelcomeWagon: nobody can sign in, and every map session ends at its next check;
    • *
    • no BlueMap: no maps;
    • *
    • a viewer who isn't in game, and no LuckPerms: no maps, and only themselves;
    • - *
    • no HouseRules: nobody but the viewer themselves on the map.
    • + *
    • no Mayor: nobody but the viewer themselves on the map.
    • *
    */ public final class LiveAccess implements Access { @@ -55,7 +55,7 @@ public void refreshMaps() { @Override public Optional redeem(String token) { - Object r = call("Latchkey", "redeemMapHandoff", new Class[]{String.class}, token); + Object r = call("WelcomeWagon", "redeemMapHandoff", new Class[]{String.class}, token); if (!(r instanceof Map m)) return Optional.empty(); Object u = m.get("uuid"), n = m.get("name"), s = m.get("session"); if (!(u instanceof String us) || !(n instanceof String ns) || !(s instanceof String ss)) return Optional.empty(); @@ -68,7 +68,7 @@ public Optional redeem(String token) { @Override public boolean live(String session) { - return Boolean.TRUE.equals(call("Latchkey", "handoffSessionLive", new Class[]{String.class}, session)); + return Boolean.TRUE.equals(call("WelcomeWagon", "handoffSessionLive", new Class[]{String.class}, session)); } @Override @@ -87,7 +87,7 @@ public boolean mayEnter(UUID viewer, String world) { public Set visible(UUID viewer, Set players) { Set out = new HashSet<>(); if (players.contains(viewer)) out.add(viewer); - if (Bukkit.getPluginManager().getPlugin("HouseRules") == null) return out; + if (Bukkit.getPluginManager().getPlugin("Mayor") == null) return out; Player me = Bukkit.getPlayer(viewer); Predicate mine = me == null ? offlinePermissions(viewer) : null; if (me == null && mine == null) return out; @@ -96,8 +96,8 @@ public Set visible(UUID viewer, Set players) { Player them = Bukkit.getPlayer(id); if (them == null) continue; Object ok = me != null - ? call("HouseRules", "mayReach", new Class[]{Player.class, Player.class}, me, them) - : call("HouseRules", "sharesCircle", new Class[]{Predicate.class, Player.class}, mine, them); + ? call("Mayor", "mayReach", new Class[]{Player.class, Player.class}, me, them) + : call("Mayor", "sharesCircle", new Class[]{Predicate.class, Player.class}, mine, them); if (Boolean.TRUE.equals(ok)) out.add(id); } return out; diff --git a/src/main/java/com/extantape/bluemapauth/web/Sessions.java b/src/main/java/com/extantape/bluemapauth/web/Sessions.java index 13cdede..4b5af12 100644 --- a/src/main/java/com/extantape/bluemapauth/web/Sessions.java +++ b/src/main/java/com/extantape/bluemapauth/web/Sessions.java @@ -16,13 +16,13 @@ import java.util.regex.Pattern; /** - * The map's own sessions (D43): one random cookie per browser, kept in memory as its SHA-256 only, tied to the Latchkey - * session it came from. Each is re-checked with Latchkey at most {@link #RECHECK_MS} apart, so signing out there, a + * The map's own sessions (D43): one random cookie per browser, kept in memory as its SHA-256 only, tied to the WelcomeWagon + * session it came from. Each is re-checked with WelcomeWagon at most {@link #RECHECK_MS} apart, so signing out there, a * revoke or a whitelist removal reaches the map within that time. A restart signs every browser out of the map. */ public final class Sessions { public static final long RECHECK_MS = 30_000; - /** However long the Latchkey session lasts, the map asks for a new hand-off after this. */ + /** However long the WelcomeWagon session lasts, the map asks for a new hand-off after this. */ public static final long MAX_AGE_MS = 24 * 60 * 60_000L; static final int MAX_SESSIONS = 10_000; private static final Pattern COOKIE = Pattern.compile("[A-Za-z0-9_-]{43}"); @@ -55,7 +55,7 @@ public synchronized Created create(Access.Viewer v) { return new Created(v, cookie); } - /** The viewer for a cookie, re-checked with Latchkey when due. Anything doubtful ends the session. */ + /** The viewer for a cookie, re-checked with WelcomeWagon when due. Anything doubtful ends the session. */ public Optional lookup(String cookie) { if (cookie == null || !COOKIE.matcher(cookie).matches()) return Optional.empty(); String h = hash(cookie); @@ -65,7 +65,7 @@ public Optional lookup(String cookie) { long now = clock.getAsLong(); if (now - e.since() > MAX_AGE_MS || now < e.since()) { end(h); return Optional.empty(); } if (now - e.checked() >= RECHECK_MS || now < e.checked()) { - // Asked outside the lock: Latchkey reads a file, and one slow answer shouldn't hold up every browser. + // Asked outside the lock: WelcomeWagon reads a file, and one slow answer shouldn't hold up every browser. if (!access.live(e.viewer().session())) { end(h); return Optional.empty(); } synchronized (this) { if (byHash.containsKey(h)) byHash.put(h, new Entry(e.viewer(), e.since(), now)); } } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 0019cec..5d82c1a 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -13,7 +13,7 @@ public-url: "" # in BlueMap's webserver.conf, set ip: "127.0.0.1". bluemap-url: "http://127.0.0.1:8100" -# Where a visitor who isn't signed in is sent to sign in: your Latchkey invite page, such as https://example.org. +# Where a visitor who isn't signed in is sent to sign in: your WelcomeWagon invite page, such as https://example.org. sign-in-url: "" # Exact addresses of the proxy in front of BlueMapAuth. Only these are believed about a visitor's real address. diff --git a/src/main/resources/paper-plugin.yml b/src/main/resources/paper-plugin.yml index 9b4422f..67c69b6 100644 --- a/src/main/resources/paper-plugin.yml +++ b/src/main/resources/paper-plugin.yml @@ -15,11 +15,11 @@ dependencies: load: BEFORE required: false join-classpath: true - Latchkey: + WelcomeWagon: load: BEFORE required: false join-classpath: false - HouseRules: + Mayor: load: BEFORE required: false join-classpath: false diff --git a/src/test/java/com/extantape/bluemapauth/web/MapServerTest.java b/src/test/java/com/extantape/bluemapauth/web/MapServerTest.java index 567cc8b..1e95b28 100644 --- a/src/test/java/com/extantape/bluemapauth/web/MapServerTest.java +++ b/src/test/java/com/extantape/bluemapauth/web/MapServerTest.java @@ -136,7 +136,7 @@ HttpResponse postHandoff(String body, String origin) throws Exception { return http.send(b.build(), HttpResponse.BodyHandlers.ofString()); } - /** A token as Latchkey would issue it, for this player and a live session. */ + /** A token as WelcomeWagon would issue it, for this player and a live session. */ String token(UUID who) { String t = UUID.randomUUID().toString().replace("-", "") + "0123456789a"; String session = "s-" + who; @@ -287,10 +287,10 @@ void oddPlayerListsShowNobody() throws Exception { } } - // --- sessions end with Latchkey's --- + // --- sessions end with WelcomeWagon's --- @Test - void signingOutOfLatchkeyEndsTheMapWithin30Seconds() throws Exception { + void signingOutOfWelcomeWagonEndsTheMapWithin30Seconds() throws Exception { String kid = signIn(KID); liveSessions.remove("s-" + KID); assertEquals(200, get("/settings.json", kid).statusCode(), "still within the 30 seconds"); diff --git a/test/live/bluemapauth.mjs b/test/live/bluemapauth.mjs index 263e4da..9b8e6a6 100644 --- a/test/live/bluemapauth.mjs +++ b/test/live/bluemapauth.mjs @@ -1,4 +1,4 @@ -// BlueMapAuth's bot test on a throwaway Paper 26.1.2 server with the real BlueMap, LuckPerms, HouseRules and Latchkey, +// BlueMapAuth's bot test on a throwaway Paper 26.1.2 server with the real BlueMap, LuckPerms, Mayor and WelcomeWagon, // driven from the console, over HTTP and with mineflayer bots. Built in a temp folder on 127.0.0.1, never a copy of a // real server, and deleted at the end, pass or fail. // @@ -11,10 +11,10 @@ // MK_TEST_JARS folder with paper-26.1.2.jar, LuckPerms-Bukkit-*.jar, bluemap-*-paper.jar // MK_TEST_EULA an eula.txt the owner already accepted. It's copied, never written. // MK_TEST_RUN where the server is built. Must be under a temp folder. -// MK_TEST_HOUSERULES a HouseRules jar with sharesCircle (0.4 or newer, or its offline-circle branch) -// MK_TEST_LATCHKEY a Latchkey jar with the map hand-off (0.4 or newer) +// MK_TEST_MAYOR a Mayor jar with sharesCircle (0.4 or newer, or its offline-circle branch) +// MK_TEST_WELCOMEWAGON a WelcomeWagon jar with the map hand-off (0.4 or newer) // MK_TEST_JAVA a Java 25 to run Paper with -// MK_TEST_MISSING=1 run without HouseRules and LuckPerms instead, to check every missing piece fails closed +// MK_TEST_MISSING=1 run without Mayor and LuckPerms instead, to check every missing piece fails closed import { spawn } from 'node:child_process' import { createHash, randomBytes } from 'node:crypto' import { copyFileSync, existsSync, mkdirSync, readFileSync, readdirSync, rmSync, writeFileSync, appendFileSync } from 'node:fs' @@ -25,7 +25,7 @@ import mineflayer from 'mineflayer' const must = n => { const v = process.env[n]; if (!v) throw new Error('Set ' + n + ' (see the top of test/live/bluemapauth.mjs)'); return v } const JAVA = process.env.MK_TEST_JAVA ?? 'java' const MISSING = process.env.MK_TEST_MISSING === '1' -const JARS = must('MK_TEST_JARS'), EULA = must('MK_TEST_EULA'), HOUSERULES = must('MK_TEST_HOUSERULES'), LATCHKEY = must('MK_TEST_LATCHKEY') +const JARS = must('MK_TEST_JARS'), EULA = must('MK_TEST_EULA'), MAYOR = must('MK_TEST_MAYOR'), WELCOMEWAGON = must('MK_TEST_WELCOMEWAGON') const RUN = path.resolve(must('MK_TEST_RUN')) if (![os.tmpdir(), '/tmp', '/private/tmp', '/var/folders'].map(p => path.resolve(p)).some(t => RUN.startsWith(t + path.sep))) throw new Error('MK_TEST_RUN must be inside a temp folder, not ' + RUN) @@ -60,13 +60,13 @@ const KID = offlineUuid('Kid'), MUM = offlineUuid('Mum'), ADULT = offlineUuid('A const dir = path.join(RUN, 'bluemapauth-26.1.2') rmSync(dir, { recursive: true, force: true }) -for (const p of ['Latchkey', 'LuckPerms', 'HouseRules', 'BlueMapAuth']) mkdirSync(path.join(dir, 'plugins', p), { recursive: true }) +for (const p of ['WelcomeWagon', 'LuckPerms', 'Mayor', 'BlueMapAuth']) mkdirSync(path.join(dir, 'plugins', p), { recursive: true }) copyFileSync(jar(/^paper-26\.1\.2\.jar$/), path.join(dir, 'paper.jar')) copyFileSync(EULA, path.join(dir, 'eula.txt')) if (!MISSING) copyFileSync(jar(/^LuckPerms-Bukkit-.*\.jar$/), path.join(dir, 'plugins/LuckPerms.jar')) copyFileSync(jar(/^bluemap-.*-paper\.jar$/), path.join(dir, 'plugins/BlueMap.jar')) -if (!MISSING) copyFileSync(HOUSERULES, path.join(dir, 'plugins/HouseRules.jar')) -copyFileSync(LATCHKEY, path.join(dir, 'plugins/Latchkey.jar')) +if (!MISSING) copyFileSync(MAYOR, path.join(dir, 'plugins/Mayor.jar')) +copyFileSync(WELCOMEWAGON, path.join(dir, 'plugins/WelcomeWagon.jar')) copyFileSync(path.join(LIBS, MK[0]), path.join(dir, 'plugins/BlueMapAuth.jar')) writeFileSync(path.join(dir, 'plugins/LuckPerms/config.yml'), 'server: global\nstorage-method: yaml\nwatch-files: false\n') writeFileSync(path.join(dir, 'server.properties'), [ @@ -84,12 +84,12 @@ function configFrom(src, dest, pairs) { writeFileSync(dest, t) } const fromJar = async (j, file) => (await import('node:child_process')).execFileSync('unzip', ['-p', j, file], { encoding: 'utf8' }) -writeFileSync(path.join(dir, 'lk.yml'), await fromJar(LATCHKEY, 'config.yml')) -configFrom(path.join(dir, 'lk.yml'), path.join(dir, 'plugins/Latchkey/config.yml'), [ +writeFileSync(path.join(dir, 'lk.yml'), await fromJar(WELCOMEWAGON, 'config.yml')) +configFrom(path.join(dir, 'lk.yml'), path.join(dir, 'plugins/WelcomeWagon/config.yml'), [ ['enabled: false', 'enabled: true'], ['port: 25680', 'port: ' + LK_WEB], ['public-url: ""', 'public-url: "' + PLAY + '"'], ['map-address: ""', 'map-address: "' + MAP + '"']]) -writeFileSync(path.join(dir, 'hr.yml'), await fromJar(HOUSERULES, 'config.yml')) -configFrom(path.join(dir, 'hr.yml'), path.join(dir, 'plugins/HouseRules/config.yml'), [['circles: []', 'circles:\n - family']]) +writeFileSync(path.join(dir, 'hr.yml'), await fromJar(MAYOR, 'config.yml')) +configFrom(path.join(dir, 'hr.yml'), path.join(dir, 'plugins/Mayor/config.yml'), [['circles: []', 'circles:\n - family']]) configFrom(path.join(ROOT, 'src/main/resources/config.yml'), path.join(dir, 'plugins/BlueMapAuth/config.yml'), [ ['enabled: false', 'enabled: true'], ['port: 8180', 'port: ' + MAP_WEB], ['public-url: ""', 'public-url: "' + MAP + '"'], ['bluemap-url: "http://127.0.0.1:8100"', 'bluemap-url: "http://127.0.0.1:' + BLUEMAP + '"'], @@ -100,7 +100,7 @@ const log = [] let proc, exited async function start(done = /Done \(\d/) { const from = log.length - proc = spawn(JAVA, ['-Xms1536M', '-Xmx1536M', '-Dterminal.jline=false', '-Dterminal.ansi=false', '-Dlatchkey.allowOfflineForTesting=true', + proc = spawn(JAVA, ['-Xms1536M', '-Xmx1536M', '-Dterminal.jline=false', '-Dterminal.ansi=false', '-Dwelcomewagon.allowOfflineForTesting=true', '-jar', 'paper.jar', 'nogui'], { cwd: dir, stdio: ['pipe', 'pipe', 'pipe'] }) exited = new Promise(r => proc.on('exit', r)) process.on('exit', () => { if (proc.exitCode === null) proc.kill('SIGKILL') }) @@ -163,20 +163,20 @@ class Browser { async csrf(p) { const m = /name="csrf" value="([^"]+)"/.exec((await this.req(p)).body); if (!m) throw new Error('no form on ' + p); return m[1] } } -/** A Latchkey session file as Latchkey writes it, for a cookie the test made. Like having used an invite. */ +/** A WelcomeWagon session file as WelcomeWagon writes it, for a cookie the test made. Like having used an invite. */ function plantSession(uuid, name) { const cookie = randomBytes(32).toString('base64url') const now = Math.floor(Date.now() / 1000) - const f = path.join(dir, 'plugins/Latchkey/sessions', createHash('sha256').update(cookie).digest('hex') + '.json') + const f = path.join(dir, 'plugins/WelcomeWagon/sessions', createHash('sha256').update(cookie).digest('hex') + '.json') mkdirSync(path.dirname(f), { recursive: true, mode: 0o700 }) writeFileSync(f, JSON.stringify({ uuid, name, expires: now + 3600, since: now }) + '\n', { mode: 0o600 }) return cookie } -/** The whole hand-off as a browser does it: Latchkey's welcome view, "Open the map", then the map's hand-off page. */ +/** The whole hand-off as a browser does it: WelcomeWagon's welcome view, "Open the map", then the map's hand-off page. */ async function openMap(uuid, name) { const lk = new Browser(LK_WEB) - lk.jar.set('latchkey_session', plantSession(uuid, name)) + lk.jar.set('welcomewagon_session', plantSession(uuid, name)) const csrf = await lk.csrf('/') const r = await lk.req('/map', { method: 'POST', form: { csrf }, headers: { origin: PLAY } }) const where = r.headers.get('location') ?? '' @@ -191,16 +191,16 @@ const mapsIn = s => { try { return JSON.parse(s).maps ?? [] } catch { return nul const playersIn = s => { try { return (JSON.parse(s).players ?? []).map(p => p.uuid) } catch { return null } } /** - * Without HouseRules and LuckPerms (MK_TEST_MISSING=1). Every missing piece answers "no": an away viewer gets no maps + * Without Mayor and LuckPerms (MK_TEST_MISSING=1). Every missing piece answers "no": an away viewer gets no maps * (no LuckPerms to read their permissions) and nobody on the map, and an in-game viewer sees only themselves (no - * HouseRules). Adult is an operator here, so has every world's permission while in game. + * Mayor). Adult is an operator here, so has every world's permission while in game. */ async function missingPieces() { send('op Adult') await sleep(1000) await bot('Mum'); await bot('Adult'); await bot('Guest') const kid = await openMap(KID, 'Kid') - check('without LuckPerms or HouseRules, the hand-off still works', kid.status === 204, String(kid.status)) + check('without LuckPerms or Mayor, the hand-off still works', kid.status === 204, String(kid.status)) const kidMaps = mapsIn((await kid.map.req('/settings.json')).body) check('an away kid gets no maps: there\'s no LuckPerms to read their permissions', Array.isArray(kidMaps) && kidMaps.length === 0, JSON.stringify(kidMaps)) check('and no players either', (await kid.map.req('/maps/world/live/players.json')).status === 404) @@ -208,13 +208,13 @@ async function missingPieces() { const adultMaps = mapsIn((await adult.map.req('/settings.json')).body) check('an operator in game gets the maps they may enter', adultMaps?.length === 3, JSON.stringify(adultMaps)) const seen = playersIn((await adult.map.req('/maps/world/live/players.json')).body) - check('but sees only themselves: no HouseRules to say who they may reach', seen?.length === 1 && seen[0] === ADULT, JSON.stringify(seen)) + check('but sees only themselves: no Mayor to say who they may reach', seen?.length === 1 && seen[0] === ADULT, JSON.stringify(seen)) const status = log.length send('bluemapauth status') await sleep(800) const said = log.slice(status).join('\n') check('/bluemapauth status names what\'s missing and what that means', /LuckPerms: missing, so someone who isn't in game sees no maps/.test(said) - && /HouseRules: missing, so the map shows nobody but the viewer themselves/.test(said)) + && /Mayor: missing, so the map shows nobody but the viewer themselves/.test(said)) } // --- the run --- @@ -245,7 +245,7 @@ try { for (const n of ['Kid', 'Mum', 'Adult', 'Guest']) send('whitelist add ' + n) if (MISSING) { await missingPieces(); throw 'done' } - const perms = [[KID, 'houserules.circle.family'], [MUM, 'houserules.circle.family'], + const perms = [[KID, 'mayor.circle.family'], [MUM, 'mayor.circle.family'], [KID, 'mktest.world.world'], [MUM, 'mktest.world.world'], [GUEST, 'mktest.world.world'], [ADULT, 'mktest.world.world'], [ADULT, 'mktest.world.world_the_end']] for (const [u, node] of perms) { send(`lp user ${u} permission set ${node} true`); await sleep(250) } @@ -304,7 +304,7 @@ try { check('back out of the game, only the circle again', awayAgain?.includes(MUM) && !awayAgain?.includes(ADULT) && !awayAgain?.includes(GUEST), JSON.stringify(awayAgain)) // --- 4. losing the circle, or the world, reaches the map --- - send(`lp user ${KID} permission unset houserules.circle.family`) + send(`lp user ${KID} permission unset mayor.circle.family`) await sleep(31000) // LuckPerms answers for an away player are kept for 30 seconds const noCircle = playersIn((await kid.map.req(`/maps/${over}/live/players.json`)).body) check('out of the circle, an away kid sees no one else', noCircle && !noCircle.includes(MUM) && !noCircle.includes(ADULT), JSON.stringify(noCircle)) @@ -314,13 +314,13 @@ try { check('without the world\'s permission, its map is gone from the kid\'s list', Array.isArray(noWorld) && noWorld.length === 0, JSON.stringify(noWorld)) check('and its players too', (await kid.map.req(`/maps/${over}/live/players.json`)).status === 404) - // --- 5. signing out of Latchkey ends the map --- + // --- 5. signing out of WelcomeWagon ends the map --- const out = await adult.lk.req('/signout', { method: 'POST', form: { csrf: await adult.lk.csrf('/') }, headers: { origin: PLAY } }) check('the adult signs out on the invite page', out.status === 303, String(out.status)) await sleep(31000) check('and within 30 seconds the map signs them out too', (await adult.map.req('/settings.json')).status === 401) - // Taken off the whitelist: Latchkey ends their sessions, so the map ends within 30 seconds; and even a session - // planted afterwards (which Latchkey would never issue) can't be handed to the map. + // Taken off the whitelist: WelcomeWagon ends their sessions, so the map ends within 30 seconds; and even a session + // planted afterwards (which WelcomeWagon would never issue) can't be handed to the map. const mum = await openMap(MUM, 'Mum') check('Mum, on the whitelist, opens the map', mum.status === 204 && (await mum.map.req('/settings.json')).status === 200, String(mum.status)) send('whitelist remove Mum')