Repository navigation
Mount optional public routes by switch, staff-only customer guards, scheduler heartbeat - #194
Merged
Merged
Conversation
escalated.widget.enabled=false (ESCALATED_WIDGET_ENABLED) now registers no
/escalated/api/widget/** route at all instead of mounting every route and
refusing each request; WidgetAvailabilityInterceptor still answers 403
{"enabled": false} under the prefix, so clients see the same answer.
escalated.guest.routes-enabled (default true, falling back to
ESCALATED_GUEST_ROUTES) does the same for the guest portal: the guest pages
under /escalated/guest and /escalated/api/guest/**. The guest_tickets_enabled
setting keeps switching guest tickets at runtime while they are mounted. The
mobile guest API is not part of the portal and is unaffected.
Verification and lookup were one controller serving both prefixes; the
widget prefix moves to WidgetVerificationController and both delegate to
GuestVerificationEndpoints, which the mobile guest API now uses too.
Also adds the escalated.routes.customer-middleware property, used by the
next commit.
The customer pages, /escalated/api/customer/** and the customer knowledge base accepted any signed-in user, so on an install only staff use, someone never given Escalated access could still list and raise tickets. Each entry is escalated-agent or escalated-admin (Escalated's own gates) or the bean name of the host's AuthorizationManager<RequestAuthorizationContext>; a request must be signed in and pass every one. Applied in the security chains, so a signed-in user who fails gets 403 and anyone else the host's sign-in entry point. Empty by default, which leaves the chains as they were. An unknown name fails at start-up.
The SLA sweep records a heartbeat (the scheduler_heartbeat_at setting) each
run. When it is missing or more than 15 minutes old, the scheduler prop
{healthy, last_run_at, message, commands: [{command, interval}]} on
Escalated/Admin/Settings, Escalated/Admin/Reports and
Escalated/Admin/Reports/Dashboard says so and names each job and its
interval; GET /escalated/api/admin/settings/scheduler returns the same object
for API-only installs, and a warning is logged once per outage, then at most
every 15 minutes.
The jobs themselves were already registered in-process with @scheduled.
Both show pages already carry ticket.subjects; the test compares them with the agent API's ticket resource so they cannot drift.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes from the bug list an Escalated host (ecom-core) reported against escalated-laravel 1.9.17, mapped to this port.
B1. Ticket subjects on the ticket pages: already fixed
AgentUiPages#showalready putsticket.subjectsfromTicketSubjectService#serializeForTicket(src/main/java/dev/escalated/ui/AgentUiPages.java:177). The agent API resource uses the same serializer (TicketService.java:168), and the admin page builds on the agent page (AdminTicketUiPages.java:82). Added a regression test (AdminTicketInertiaPagesTest#bothTicketPagesCarryTheSubjectsAsTheApiSerialisesThem) that compares both pages withGET /escalated/api/agent/tickets/{id}.B2. Optional public routes only when their feature is on: fixed
escalated.widget.enabled(default true, envESCALATED_WIDGET_ENABLED) already existed but only refused each request with 403. With it false, no/escalated/api/widget/**route is registered at all now (WidgetRoutesConditionon every widget controller).WidgetAvailabilityInterceptorstill answers 403{"enabled": false}under the prefix, so clients see the same answer as before.escalated.guest.routes-enabled(default true, falls back to envESCALATED_GUEST_ROUTES). False registers neither the guest pages (/escalated/guest/**) nor/escalated/api/guest/**. The runtimeguest_tickets_enabledsetting still works while they are mounted. The mobile guest API is a separate surface and is unaffected.WidgetVerificationController, and both controllers delegate to a newGuestVerificationEndpoints, whichMobileGuestControllernow uses.PluginSlugs.java).src/test/resources/embed/default-routes.json) changes only for the two widget verification handler names and the new scheduler status route. Gates, chains and filters are unchanged.PublicRouteSwitchesTest(defaults mounted; env fallback),GuestRoutesSwitchedOffTest,WidgetDisabledTest#noWidgetRouteIsRegistered(plus the bundle, verification and lookup added to its 403 list).B3. Staff-only installs: fixed
New
escalated.routes.customer-middleware(default empty). It is applied in the Spring Security chains to the customer pages,/escalated/api/customer/**and the customer knowledge base (/escalated/kb/**). Each entry isescalated-agentorescalated-admin(Escalated's gates), or the bean name of the host'sAuthorizationManager<RequestAuthorizationContext>. A request must be signed in and pass every entry: a signed-in user who fails gets 403, and anyone else goes to the host's sign-in entry point. An unknown name fails at start-up. With the list empty the chains are exactly as before, which the route snapshot confirms. docs/getting-started.md has a "A staff-only install" section that combines it with the B2 switches. Tests:CustomerMiddlewareTest;PublicRouteSwitchesTest#anySignedInUserStillReachesTheCustomerRoutesByDefault.B4. Recurring jobs: fixed (heartbeat and warning); auto-registration already present
@EnableSchedulingonEscalatedAutoConfiguration(EscalatedAutoConfiguration.java:40) and@ScheduledonSlaScheduler#checkSlaBreaches,AutomationScheduler#runAutomationsand#autoCloseResolvedTickets, andSnoozeScheduler#wakeUpSnoozedTickets. Nothing to add.SlaScheduler#checkSlaBreachesrun writes thescheduler_heartbeat_atsetting, in the settings table this port already uses for runtime state.schedulerprop{healthy, last_run_at, message, commands: [{command, interval}]}onEscalated/Admin/Settings,Escalated/Admin/ReportsandEscalated/Admin/Reports/Dashboard.healthyis false when the heartbeat is missing or more than 15 minutes old, and the message and commands then name each job and its interval. API-only installs get the same object atGET /escalated/api/admin/settings/scheduler(admin,settings.view). A warning is logged once per outage, then at most every 15 minutes.SchedulerHeartbeatTest(the scheduled run writes the heartbeat; missing, stale and recent heartbeats; the props on all three pages; the API; the log warning).B5. Unclear failure when the host user is not set up: N/A
This port has no host user type to implement. The caller is Spring Security's
Authentication, matched by principal name toescalated_agent_profilesor to theROLE_ESCALATED_ADMIN/ROLE_ESCALATED_AGENTauthorities (EscalatedAuthorization.java:69-98). Nothing casts the principal (nogetPrincipal()in src/main). A user with neither a profile nor a role fails the gate with 403, not a type error. Staff actions with no profile resolveagentIdto null and carry on (for exampleTicketWritesController.java:218,238). There is also no install or status command to add a setup check to.Verification
./gradlew checkstyleMain checkstyleTest testlocally (H2, JDK 21 compiling to 17): 1102 tests. The only failure before the snapshot update was the expected route-table diff, andDefaultRouteTableTestpasses after it.