Compare commits

...
3 Commits
Author SHA1 Message Date
dmg e43db34402 feat(admin): show recent address locations
CI / validate (push) Successful in 5m59s
Release / release (push) Successful in 7m38s
2026-08-07 19:09:33 -04:00
dmg 20dfc58d63 fix(admin): prefer non-anonymized map locations
CI / validate (push) Successful in 6m9s
Release / release (push) Successful in 8m18s
2026-08-07 18:36:59 -04:00
dmg 6425a5056a fix(release): publish versioned images to Docker Hub
CI / validate (push) Successful in 9m32s
Release / release (push) Successful in 13m11s
2026-08-03 20:36:06 -04:00
10 changed files with 94 additions and 34 deletions
+8 -9
View File
@@ -7,7 +7,6 @@ on:
permissions: permissions:
contents: write contents: write
packages: write
jobs: jobs:
release: release:
@@ -116,9 +115,9 @@ jobs:
apt-get install -y docker-ce-cli apt-get install -y docker-ce-cli
fi fi
- name: Log in to Gitea container registry - name: Log in to Docker Hub
if: steps.release.outputs.created == 'true' if: steps.release.outputs.created == 'true'
run: echo "${{ secrets.CONTAINER_REGISTRY_TOKEN }}" | docker login git.garvis.dev -u "${{ secrets.REGISTRY_USERNAME }}" --password-stdin run: echo "${{ secrets.DOCKERHUB_TOKEN }}" | docker login -u "${{ secrets.DOCKERHUB_USERNAME }}" --password-stdin
- name: Build and push web image - name: Build and push web image
if: steps.release.outputs.created == 'true' if: steps.release.outputs.created == 'true'
@@ -129,9 +128,9 @@ jobs:
--platform linux/amd64 \ --platform linux/amd64 \
--target runner \ --target runner \
--build-arg VERSION="$VERSION" \ --build-arg VERSION="$VERSION" \
-t "git.garvis.dev/dmg/minecraft-account-manager:${VERSION}" \ -t "dmgarvis/minecraft-account-manager:${VERSION}" \
. .
docker push "git.garvis.dev/dmg/minecraft-account-manager:${VERSION}" docker push "dmgarvis/minecraft-account-manager:${VERSION}"
- name: Build and push Discord bot image - name: Build and push Discord bot image
if: steps.release.outputs.created == 'true' if: steps.release.outputs.created == 'true'
@@ -142,9 +141,9 @@ jobs:
--platform linux/amd64 \ --platform linux/amd64 \
--target bot \ --target bot \
--build-arg VERSION="$VERSION" \ --build-arg VERSION="$VERSION" \
-t "git.garvis.dev/dmg/minecraft-account-manager-bot:${VERSION}" \ -t "dmgarvis/minecraft-account-manager-bot:${VERSION}" \
. .
docker push "git.garvis.dev/dmg/minecraft-account-manager-bot:${VERSION}" docker push "dmgarvis/minecraft-account-manager-bot:${VERSION}"
- name: Build and push migration image - name: Build and push migration image
if: steps.release.outputs.created == 'true' if: steps.release.outputs.created == 'true'
@@ -155,9 +154,9 @@ jobs:
--platform linux/amd64 \ --platform linux/amd64 \
--target migrate \ --target migrate \
--build-arg VERSION="$VERSION" \ --build-arg VERSION="$VERSION" \
-t "git.garvis.dev/dmg/minecraft-account-manager-migrate:${VERSION}" \ -t "dmgarvis/minecraft-account-manager-migrate:${VERSION}" \
. .
docker push "git.garvis.dev/dmg/minecraft-account-manager-migrate:${VERSION}" docker push "dmgarvis/minecraft-account-manager-migrate:${VERSION}"
- name: Create Gitea release and upload Velocity JAR - name: Create Gitea release and upload Velocity JAR
if: steps.release.outputs.created == 'true' if: steps.release.outputs.created == 'true'
+2 -1
View File
@@ -5,7 +5,7 @@ import Link from "next/link";
import { UserWorldMap, type UserMapLocation } from "@/components/user-world-map"; import { UserWorldMap, type UserMapLocation } from "@/components/user-world-map";
import { db } from "@/lib/database"; import { db } from "@/lib/database";
import { fillDailySeries, mergeRiskActivity, type DailyCount } from "@/lib/admin-metrics"; import { fillDailySeries, mergeRiskActivity, type DailyCount } from "@/lib/admin-metrics";
import { parseUserLocation, parseUserNetwork } from "@/lib/user-location-map"; import { MAP_LOCATION_CLASSIFICATIONS, parseUserLocation, parseUserNetwork } from "@/lib/user-location-map";
export const dynamic = "force-dynamic"; export const dynamic = "force-dynamic";
@@ -58,6 +58,7 @@ export default async function AdminDashboardPage() {
)) ))
.where(and( .where(and(
isNotNull(ipObservations.userId), isNotNull(ipObservations.userId),
inArray(ipIntelligence.classification, MAP_LOCATION_CLASSIFICATIONS),
sql`case when jsonb_typeof(${ipIntelligence.rawResponse}->'location'->'latitude') = 'number' then (${ipIntelligence.rawResponse}->'location'->>'latitude')::double precision between -90 and 90 else false end`, sql`case when jsonb_typeof(${ipIntelligence.rawResponse}->'location'->'latitude') = 'number' then (${ipIntelligence.rawResponse}->'location'->>'latitude')::double precision between -90 and 90 else false end`,
sql`case when jsonb_typeof(${ipIntelligence.rawResponse}->'location'->'longitude') = 'number' then (${ipIntelligence.rawResponse}->'location'->>'longitude')::double precision between -180 and 180 else false end`, sql`case when jsonb_typeof(${ipIntelligence.rawResponse}->'location'->'longitude') = 'number' then (${ipIntelligence.rawResponse}->'location'->>'longitude')::double precision between -180 and 180 else false end`,
)) ))
@@ -1,10 +1,10 @@
import { resolveEffectiveGroup } from "@minecraft-account-manager/auth"; import { resolveEffectiveGroup } from "@minecraft-account-manager/auth";
import { formatManagedDiscordNickname } from "@minecraft-account-manager/minecraft"; import { formatManagedDiscordNickname } from "@minecraft-account-manager/minecraft";
import { events, groups, ipObservations, minecraftAccounts, userGroupMemberships, users } from "@minecraft-account-manager/database"; import { events, groups, ipIntelligence, ipObservations, minecraftAccounts, userGroupMemberships, users } from "@minecraft-account-manager/database";
import { and, desc, eq, inArray, isNull, or } from "drizzle-orm"; import { and, desc, eq, inArray, isNull, or } from "drizzle-orm";
import Link from "next/link"; import Link from "next/link";
import { notFound } from "next/navigation"; import { notFound } from "next/navigation";
import { groupAccessAddresses } from "@/lib/access-address-groups"; import { accessAddressDetails, groupAccessAddresses } from "@/lib/access-address-groups";
import { db } from "@/lib/database"; import { db } from "@/lib/database";
import { discordIdentity } from "@/lib/discord-identity"; import { discordIdentity } from "@/lib/discord-identity";
import { eventCategory, eventCategoryValues, normalizeEventCategory, normalizeSelectedEventTypes } from "@/lib/event-filters"; import { eventCategory, eventCategoryValues, normalizeEventCategory, normalizeSelectedEventTypes } from "@/lib/event-filters";
@@ -80,8 +80,16 @@ export default async function AdminUserPage({
.orderBy(desc(minecraftAccounts.isPrimary), minecraftAccounts.username), .orderBy(desc(minecraftAccounts.isPrimary), minecraftAccounts.username),
recentEventsQuery, recentEventsQuery,
db db
.select() .select({
id: ipObservations.id,
ipAddress: ipObservations.ipAddress,
source: ipObservations.source,
classification: ipObservations.classification,
observedAt: ipObservations.observedAt,
intelligence: ipIntelligence.rawResponse,
})
.from(ipObservations) .from(ipObservations)
.leftJoin(ipIntelligence, eq(ipIntelligence.ipAddress, ipObservations.ipAddress))
.where(eq(ipObservations.userId, user.id)) .where(eq(ipObservations.userId, user.id))
.orderBy(desc(ipObservations.observedAt)) .orderBy(desc(ipObservations.observedAt))
.limit(100), .limit(100),
@@ -95,9 +103,7 @@ export default async function AdminUserPage({
const explicitGroup = availableGroups.find((group) => !group.isDefault) ?? null; const explicitGroup = availableGroups.find((group) => !group.isDefault) ?? null;
const defaultGroup = availableGroups.find((group) => group.isDefault) ?? null; const defaultGroup = availableGroups.find((group) => group.isDefault) ?? null;
const effectiveGroup = resolveEffectiveGroup(explicitGroup, defaultGroup); const effectiveGroup = resolveEffectiveGroup(explicitGroup, defaultGroup);
const addressGroups = groupAccessAddresses( const addressGroups = groupAccessAddresses(observations);
observations.map((observation) => ({ ...observation, intelligence: null })),
);
const primary = accounts.find((account) => account.isPrimary); const primary = accounts.find((account) => account.isPrimary);
const nickname = user.firstName const nickname = user.firstName
? formatManagedDiscordNickname(user.firstName, primary?.username ?? null) ? formatManagedDiscordNickname(user.firstName, primary?.username ?? null)
@@ -215,7 +221,9 @@ export default async function AdminUserPage({
<p className="font-mono text-[9px] font-bold uppercase tracking-widest text-muted">Recent addresses</p> <p className="font-mono text-[9px] font-bold uppercase tracking-widest text-muted">Recent addresses</p>
<p className="mt-3 text-[10px] leading-5 text-muted">Grouped by IPv4 /24 or IPv6 /64 network across the 100 most recent observations.</p> <p className="mt-3 text-[10px] leading-5 text-muted">Grouped by IPv4 /24 or IPv6 /64 network across the 100 most recent observations.</p>
<div className="mt-4 divide-y divide-line"> <div className="mt-4 divide-y divide-line">
{addressGroups.map((group) => ( {addressGroups.map((group) => {
const details = accessAddressDetails(group);
return (
<div className="py-3" key={group.network}> <div className="py-3" key={group.network}>
<div className="flex items-center justify-between gap-3"> <div className="flex items-center justify-between gap-3">
<p className="font-mono text-xs font-bold">{group.network}</p> <p className="font-mono text-xs font-bold">{group.network}</p>
@@ -223,8 +231,10 @@ export default async function AdminUserPage({
</div> </div>
<p className="mt-1 font-mono text-[9px] text-muted">{group.sources.join(" + ")} · {group.latestObservedAt.toISOString()}</p> <p className="mt-1 font-mono text-[9px] text-muted">{group.sources.join(" + ")} · {group.latestObservedAt.toISOString()}</p>
<p className="mt-1 break-all font-mono text-[9px] text-muted">Latest {group.latestAddress}</p> <p className="mt-1 break-all font-mono text-[9px] text-muted">Latest {group.latestAddress}</p>
<p className="mt-1 text-xs text-muted">{details.location} · <span className="font-mono uppercase">{details.classification}</span></p>
</div> </div>
))} );
})}
{!addressGroups.length && <p className="py-3 text-xs text-muted">No addresses recorded.</p>} {!addressGroups.length && <p className="py-3 text-xs text-muted">No addresses recorded.</p>}
</div> </div>
</section> </section>
+16 -1
View File
@@ -1,5 +1,5 @@
import { describe, expect, it } from "vitest"; import { describe, expect, it } from "vitest";
import { groupAccessAddresses } from "./access-address-groups"; import { accessAddressDetails, groupAccessAddresses } from "./access-address-groups";
describe("groupAccessAddresses", () => { describe("groupAccessAddresses", () => {
it("collapses repeated observations from the same network into one recent summary", () => { it("collapses repeated observations from the same network into one recent summary", () => {
@@ -20,4 +20,19 @@ describe("groupAccessAddresses", () => {
}); });
expect(groups[0]?.latestObservedAt.toISOString()).toBe("2026-08-01T12:00:00.000Z"); expect(groups[0]?.latestObservedAt.toISOString()).toBe("2026-08-01T12:00:00.000Z");
}); });
it("presents the latest enriched location and classification with observation fallbacks", () => {
expect(accessAddressDetails({
classification: "vpn",
intelligence: {
classification: "vpn",
location: { city: "Toronto", region: "Ontario", countryCode: "CA" },
},
})).toEqual({ location: "Toronto, Ontario, CA", classification: "vpn" });
expect(accessAddressDetails({ classification: "hosting", intelligence: null })).toEqual({
location: "Location unavailable",
classification: "hosting",
});
});
}); });
@@ -1,4 +1,5 @@
import { addressGroup } from "@minecraft-account-manager/network"; import { addressGroup } from "@minecraft-account-manager/network";
import { intelligenceSummary } from "./event-ip-summary";
type AccessObservation = { type AccessObservation = {
id: string; id: string;
@@ -9,6 +10,14 @@ type AccessObservation = {
intelligence: Record<string, unknown> | null; intelligence: Record<string, unknown> | null;
}; };
export function accessAddressDetails(observation: Pick<AccessObservation, "classification" | "intelligence">) {
const summary = intelligenceSummary(observation.intelligence);
return {
location: summary.location ?? "Location unavailable",
classification: summary.classification ?? observation.classification,
};
}
export type AccessAddressGroup = { export type AccessAddressGroup = {
network: string; network: string;
latestAddress: string; latestAddress: string;
+14 -1
View File
@@ -1,7 +1,20 @@
import { describe, expect, it } from "vitest"; import { describe, expect, it } from "vitest";
import { groupMapLocations, parseUserLocation, parseUserNetwork, projectWorldPoint } from "./user-location-map"; import {
MAP_LOCATION_CLASSIFICATIONS,
groupMapLocations,
parseUserLocation,
parseUserNetwork,
projectWorldPoint,
} from "./user-location-map";
describe("user location map", () => { describe("user location map", () => {
it("allows only clear and hosting observations as map locations", () => {
expect(MAP_LOCATION_CLASSIFICATIONS).toEqual(["clear", "hosting"]);
expect(MAP_LOCATION_CLASSIFICATIONS).not.toContain("vpn");
expect(MAP_LOCATION_CLASSIFICATIONS).not.toContain("proxy");
expect(MAP_LOCATION_CLASSIFICATIONS).not.toContain("tor");
});
it("extracts a valid approximate location from cached IP intelligence", () => { it("extracts a valid approximate location from cached IP intelligence", () => {
expect(parseUserLocation({ expect(parseUserLocation({
classification: "clear", classification: "clear",
+2
View File
@@ -1,5 +1,7 @@
type UnknownMap = Record<string, unknown>; type UnknownMap = Record<string, unknown>;
export const MAP_LOCATION_CLASSIFICATIONS = ["clear", "hosting"] as const;
function objectValue(value: unknown): UnknownMap | null { function objectValue(value: unknown): UnknownMap | null {
return value && typeof value === "object" && !Array.isArray(value) return value && typeof value === "object" && !Array.isArray(value)
? value as UnknownMap ? value as UnknownMap
+5
View File
@@ -1,5 +1,10 @@
# Design Update Log # Design Update Log
## 2026-08-07
* **Extend**: Show each grouped recent address's latest approximate location and network classification on administrator user records.
* **Refine**: Select each admin map marker from the user's latest coordinate-bearing clear or hosting observation while keeping VPN, proxy, and Tor activity in the network-risk view.
## 2026-08-02 ## 2026-08-02
* **Extend**: Add recurring UTC group-access windows, browser-local schedule editing, and validated static denial-message variables. * **Extend**: Add recurring UTC group-access windows, browser-local schedule editing, and validated static denial-message variables.
+5 -2
View File
@@ -3,7 +3,7 @@ type: User Story
title: Manage users as an administrator title: Manage users as an administrator
description: Authorized operators search users and maintain their names, linked accounts, primaries, and Discord nicknames. description: Authorized operators search users and maintain their names, linked accounts, primaries, and Discord nicknames.
tags: [admin, users, minecraft, discord] tags: [admin, users, minecraft, discord]
timestamp: 2026-08-02T15:03:59Z timestamp: 2026-08-07T23:02:04Z
story_id: US-013 story_id: US-013
status: verified status: verified
--- ---
@@ -17,6 +17,9 @@ As an administrator, I want to manage a user's identity and Minecraft accounts,
- [x] Administrators can search by preferred name, Discord username or ID, Minecraft username, or UUID. - [x] Administrators can search by preferred name, Discord username or ID, Minecraft username, or UUID.
- [x] Search results show onboarding state, primary username, and active account count. - [x] Search results show onboarding state, primary username, and active account count.
- [x] A user detail view shows Discord display name, username, guild nickname, immutable ID, active accounts, groups, recent events, and recent IP observations. - [x] A user detail view shows Discord display name, username, guild nickname, immutable ID, active accounts, groups, recent events, and recent IP observations.
- [x] Each grouped recent address shows the latest observation's approximate location and classification, including clear, VPN, proxy, Tor, hosting, and unknown classifications.
- [x] Missing IP enrichment is labelled as location unavailable and falls back to the stored observation classification.
- [x] Address groups use the enrichment associated with their latest observation.
- [x] Administrators can update the preferred name and synchronize Discord. - [x] Administrators can update the preferred name and synchronize Discord.
- [x] Administrators can add Mojang-verified accounts or explicitly override an unverified username. - [x] Administrators can add Mojang-verified accounts or explicitly override an unverified username.
- [x] Administrators can remove an account only after a visible confirmation step. - [x] Administrators can remove an account only after a visible confirmation step.
@@ -43,7 +46,7 @@ As an administrator, I want to manage a user's identity and Minecraft accounts,
# Validation # Validation
Nickname fallback behavior is tested in [`packages/minecraft/test/minecraft.test.ts`](../packages/minecraft/test/minecraft.test.ts). Privileged routes pass TypeScript, lint, Semgrep, and production build checks. Nickname fallback behavior is tested in [`packages/minecraft/test/minecraft.test.ts`](../packages/minecraft/test/minecraft.test.ts). Latest-observation enrichment and classification fallback are covered by [`apps/web/src/lib/access-address-groups.test.ts`](../apps/web/src/lib/access-address-groups.test.ts). The full 107-test suite, TypeScript, lint, OKF validation, and the production build pass.
# Related Stories # Related Stories
+8 -5
View File
@@ -3,7 +3,7 @@ type: User Story
title: Monitor community account activity title: Monitor community account activity
description: Administrators use a server-rendered dashboard to review daily activity, confirmed connections, locations, denials, and risky networks. description: Administrators use a server-rendered dashboard to review daily activity, confirmed connections, locations, denials, and risky networks.
tags: [admin, dashboard, metrics, security, maps, ssr] tags: [admin, dashboard, metrics, security, maps, ssr]
timestamp: 2026-08-02T12:05:27Z timestamp: 2026-08-07T22:31:05Z
story_id: US-018 story_id: US-018
status: verified status: verified
--- ---
@@ -15,7 +15,9 @@ As an administrator, I want an operational dashboard of account and game activit
# Acceptance Criteria # Acceptance Criteria
- [x] The administrator landing page is a dashboard rather than a settings form. - [x] The administrator landing page is a dashboard rather than a settings form.
- [x] A server-rendered Natural Earth overview plots each user's latest observation with valid approximate coordinates. - [x] A server-rendered Natural Earth overview plots each user's latest non-anonymized observation with valid approximate coordinates, allowing clear and hosting classifications while excluding VPN, proxy, and Tor observations.
- [x] When a user's newest coordinate-bearing observation is VPN, proxy, or Tor, the map uses that user's older clear or hosting observation when one exists.
- [x] A user without a coordinate-bearing clear or hosting observation is counted as unavailable on the map.
- [x] Administrators can opt into a zoomable OpenStreetMap view without removing the default overview. - [x] Administrators can opt into a zoomable OpenStreetMap view without removing the default overview.
- [x] OpenStreetMap tiles load only after the administrator selects the interactive view and retain required attribution. - [x] OpenStreetMap tiles load only after the administrator selects the interactive view and retain required attribution.
- [x] Map markers show the managed Discord nickname on hover or keyboard focus, link to user records, and have an accessible text-table equivalent. - [x] Map markers show the managed Discord nickname on hover or keyboard focus, link to user records, and have an accessible text-table equivalent.
@@ -31,7 +33,7 @@ As an administrator, I want an operational dashboard of account and game activit
- [x] Monthly active users count distinct users observed through portal or game activity in the previous 30 days. - [x] Monthly active users count distinct users observed through portal or game activity in the previous 30 days.
- [x] Monthly active Minecraft accounts count distinct accounts with a confirmed Velocity post-login connection in the previous 30 days. - [x] Monthly active Minecraft accounts count distinct accounts with a confirmed Velocity post-login connection in the previous 30 days.
- [x] The dashboard shows login denials from the previous 24 hours. - [x] The dashboard shows login denials from the previous 24 hours.
- [x] Recent VPN, proxy, and Tor observations use enriched ProxyCheck classifications, collapse repeated rows per user, and show counts, sources, and latest activity. - [x] Recent VPN, proxy, and Tor observations remain available in the separate network-risk section when excluded from map-location selection.
- [x] The graph includes an accessible title, description, point labels, and textual values. - [x] The graph includes an accessible title, description, point labels, and textual values.
- [x] Dashboard queries and initial rendering execute server-side; only the opt-in pan-and-zoom map hydrates client-side. - [x] Dashboard queries and initial rendering execute server-side; only the opt-in pan-and-zoom map hydrates client-side.
- [x] Deployment-managed guild settings and denial messaging remain available on a dedicated settings page. - [x] Deployment-managed guild settings and denial messaging remain available on a dedicated settings page.
@@ -48,8 +50,9 @@ As an administrator, I want an operational dashboard of account and game activit
# Validation # Validation
- Missing-day chart behavior and per-user VPN collapsing are covered by [`apps/web/src/lib/admin-metrics.test.ts`](../apps/web/src/lib/admin-metrics.test.ts). - Missing-day chart behavior and per-user VPN collapsing are covered by [`apps/web/src/lib/admin-metrics.test.ts`](../apps/web/src/lib/admin-metrics.test.ts).
- Coordinate parsing, backward-compatible ProxyCheck network parsing, normalized location grouping, projection, count badges, complete grouped tooltips, linked markers, semantic network columns, text fallback, and attribution are covered by the user-world-map tests. - Coordinate parsing, the clear/hosting map policy, backward-compatible ProxyCheck network parsing, normalized location grouping, projection, count badges, complete grouped tooltips, linked markers, semantic network columns, text fallback, and attribution are covered by the user-location and user-world-map tests.
- The Next.js production build reports the dashboard and database-backed console pages as dynamic server-rendered routes. - The full test suite passes with 106 tests across 36 files; web type checking and lint pass.
- The Next.js production build succeeds and reports the dashboard and database-backed console pages as dynamic server-rendered routes.
# Related Stories # Related Stories