feat(admin): Policy listing + Diagnostics + Settings + custom metrics (Phase A3)#13
Merged
Merged
Conversation
Phase A3 — last big backend gap before admin-ui pages can drive every
feature the kit exposes.
## admin-api: 4 new controllers
PolicyAdminController (/admin/api/v1/policies)
- GET / list registered Policy bean names
- POST /{name}/test dry-run evaluate with a PolicyContext, returns
ALLOW / DENY / NOT_APPLICABLE
- DefaultPolicyEvaluator gains registeredNames() for the listing path.
SettingsAdminController (/admin/api/v1/settings)
- GET / read-only view of devslab.kit.* properties
- Sensitive fields (jwt.secret) masked with "***".
- Implemented against Environment rather than DevslabKitProperties to
keep the dependency graph acyclic (admin-api must not depend on
autoconfigure, which already depends on admin-api).
- Mutating settings at runtime needs RefreshScope / external config;
deliberately out of scope.
DiagnosticsController (/admin/api/v1/diagnostics)
- POST /login-test run LoginCommand through LocalLoginService;
returns success + reason; note this does
increment the lockout counter, so admins
should be careful using it as a probe.
- POST /permission-check {userId, permissionCode} -> {allowed, userPermissionCodes}
- GET /menu-visibility?userId= filter the user's tenant's menu tree
by the permission codes that user actually has
(uses MenuTreeBuilder + manual filter rather
than PermissionBasedMenuFilter so it doesn't
hijack the current SecurityContext)
TenantAdminController (already shipped in PR #12) sits alongside these.
## autoconfigure: MetricsAutoConfiguration
Per planning §13. Listens to identity events and increments
Micrometer counters with tenant + reason tags:
devslab.identity.login.success {tenant}
devslab.identity.login.failure {tenant, reason}
Activated by @ConditionalOnClass(MeterRegistry.class). Consumer apps
that ship spring-boot-starter-actuator get the counters at
/actuator/metrics/{name}; apps that don't pull Micrometer skip the
listener entirely.
Registered in AutoConfiguration.imports.
micrometer-core added as compileOnly to autoconfigure so we don't
force the dep on apps that don't want metrics.
Verified: ./gradlew :devslab-kit-sample-app:test -> BUILD SUCCESSFUL in 1m 8s
- All 4 new controllers wire
- MetricsAutoConfiguration activates (actuator is on sample-app's classpath)
- All previous beans, login flow, tenant CRUD still green
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.
Summary
Phase A3 — last big backend gap before the admin-ui pages can drive every feature the kit exposes. Adds 4 new controllers + a metrics autoconfig.
admin-api (4 new controllers)
PolicyAdminController—/admin/api/v1/policies/Policybean names/{name}/testPolicyContext→ALLOW/DENY/NOT_APPLICABLEDefaultPolicyEvaluatorgainsregisteredNames()for the listing path.SettingsAdminController—/admin/api/v1/settings/devslab.kit.*properties (jwt.secret masked)Implemented against
Environmentrather thanDevslabKitPropertiesto keep the dependency graph acyclic —admin-apimust not depend onautoconfigure, which already depends onadmin-api. Mutating settings at runtime needsRefreshScope/ external config; out of scope.DiagnosticsController—/admin/api/v1/diagnostics/login-testLoginCommandthroughLocalLoginService; returns success + reason. Note: this increments the real lockout counter — admins should be careful using it as a probe./permission-check{userId, permissionCode}→{allowed, userPermissionCodes}/menu-visibility?userId=MenuTreeBuilder+ manual filter rather thanPermissionBasedMenuFilterso it doesn't hijack the currentSecurityContext)(
TenantAdminControllerfrom PR #12 sits alongside these.)autoconfigure:
MetricsAutoConfiguration(planning §13)Listens to identity events and increments Micrometer counters with tenant + reason tags:
@ConditionalOnClass(MeterRegistry.class)spring-boot-starter-actuatorget the counters at/actuator/metrics/{name}AutoConfiguration.importsmicrometer-coreadded ascompileOnlyto autoconfigure — no forced dep on apps that don't want metrics.Verified
MetricsAutoConfigurationactivates (actuator is on sample-app's classpath)Deferred
springdoc-openapirelease (current 2.7.0 callsorg.springframework.data.util.TypeInformationwhich Spring Data 4 moved)