feat(auth): JWT login endpoint + Spring Security chain for /admin/api/v1#11
Merged
Conversation
Phase A1 of the admin console plan. Adds:
identity-api:
- AuthToken (record: value + issuedAt + expiresAt)
- AuthTokenService (interface: issue/parse)
identity-core:
- JjwtAuthTokenService — jjwt 0.12 HS256
* issue(CurrentUser): packs subject/tenant/publicId/loginId/status/roles
into a signed JWT with configurable issuer + TTL
* parse(token): verifies signature + issuer + expiry, hydrates CurrentUser
- jjwt-api/-impl/-jackson 0.12.6 deps (BOM-free, version-pinned)
DevslabKitProperties.Identity gains nested `Jwt`:
devslab.kit.identity.jwt.secret (required, default placeholder; min 32B HS256)
devslab.kit.identity.jwt.ttl (default PT8H)
devslab.kit.identity.jwt.issuer (default "devslab-kit")
IdentityAutoConfiguration: @ConditionalOnMissingBean AuthTokenService bean.
admin-api:
- AuthController POST /admin/api/v1/auth/login → calls LocalLoginService
→ AuthTokenService.issue → returns { token, expiresAt, user{...} }
- JwtAuthenticationFilter (OncePerRequestFilter): Bearer header →
AuthTokenService.parse → UsernamePasswordAuthenticationToken with
roles mapped to ROLE_* GrantedAuthorities
- AdminSecurityConfig.SecurityFilterChain (@ConditionalOnMissingBean):
* securityMatcher /admin/api/v1/**
* CSRF off (stateless API), SessionCreationPolicy.STATELESS
* /admin/api/v1/auth/login permitAll, rest authenticated
* JwtAuthenticationFilter before UsernamePasswordAuthenticationFilter
- New dep: spring-boot-starter-security
Springdoc (Phase A4) was attempted but springdoc-openapi 2.7.0 calls
org.springframework.data.util.TypeInformation, which Spring Data 4
(bundled with Spring Boot 4.0) relocated/removed → processTestAot fails
in the AOT pipeline. Deferred until a Spring Boot 4 compatible
springdoc release (or switch to swagger-ui-dist + manual OpenAPI gen).
Verified: ./gradlew :devslab-kit-sample-app:test -> BUILD SUCCESSFUL in 57s
- ApplicationContext boots with the new SecurityFilterChain
- All existing beans + V1-V6 migrations still green
- (Login round-trip via HTTP exercised by upcoming admin-ui Playwright PR)
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 A1 of the admin console plan — wires the actual
POST /admin/api/v1/auth/loginREST endpoint, a JWT issuer, and a JWT-aware Spring Security filter chain that protects/admin/api/v1/**. Unblocks the admin-ui Login page.Phase A4 (springdoc Swagger UI) was attempted in the same branch but
springdoc-openapi 2.7.0calls into Spring Data Commons 3 (org.springframework.data.util.TypeInformation), which Spring Data 4 (bundled with Spring Boot 4.0) moved/removed →processTestAotblows up. Deferred until a Spring Boot 4 compatible springdoc release ships, or until we vendorswagger-ui-dist+ emit OpenAPI 3 manually.What lands
identity-api
AuthTokenrecord — value + issuedAt + expiresAtAuthTokenServiceinterface —issue(CurrentUser)/parse(token)identity-core
JjwtAuthTokenService— jjwt 0.12 HS256CurrentUserio.jsonwebtoken:jjwt-api / -impl / -jackson0.12.6autoconfigure
DevslabKitProperties.IdentitynestedJwt:devslab.kit.identity.jwt.secretdevslab.kit.identity.jwt.ttlPT8Hdevslab.kit.identity.jwt.issuerdevslab-kitIdentityAutoConfiguration:@ConditionalOnMissingBean AuthTokenServicebeanadmin-api
AuthController—POST /admin/api/v1/auth/login→LocalLoginService.login→AuthTokenService.issue→ returns{ token, expiresAt, user{...} }JwtAuthenticationFilter(OncePerRequestFilter) — Bearer header →AuthTokenService.parse→UsernamePasswordAuthenticationTokenwith roles mapped toROLE_*GrantedAuthorityAdminSecurityConfig.SecurityFilterChain(@ConditionalOnMissingBean):securityMatcher /admin/api/v1/**SessionCreationPolicy.STATELESSPOST /admin/api/v1/auth/login→permitAll, rest →authenticatedJwtAuthenticationFilterbeforeUsernamePasswordAuthenticationFilterspring-boot-starter-securityVerified
Operator note
In production set
devslab.kit.identity.jwt.secretto a long random string (min 32 UTF-8 bytes). Default value is a placeholder —JjwtAuthTokenServicethrows on construction if the key is shorter than 256 bits.Follow-ups (separate PRs)
swagger-ui-dist+ manual OpenAPI generation