fix(authserver): strip unused OIDC/JWK/JWT — ESPI is opaque-only#135
Merged
Conversation
Closes #134. ESPI 4.0 uses opaque access tokens only and the GBA Resource Server carries no JWK/JWT. The auth-server carried OIDC + JWK/JWT-signing machinery the opaque flow never exercises. Removed it; the opaque token mint + RFC 7662 introspection path is unchanged. AuthorizationServerConfig: - Removed .oidc(...) from the authorization-server configurer. - Removed the .oauth2ResourceServer().jwt(...) self-protection added in #128. The auth-server no longer validates bearer tokens on its own endpoints: OAuth2 protocol endpoints (token/introspect/revoke) authenticate clients via client_secret_basic; admin/UI endpoints are protected by the @order(2) session-login chain (#122 design §5). - Removed jwkSource()/jwtDecoder() beans, generateRsaKey(), the .jwkSetEndpoint() declaration, and all JWK/JWT imports. application.yml: - Excluded OAuth2AuthorizationServerJwtAutoConfiguration so Spring Boot no longer auto-generates a JWKSource / stands up /oauth2/jwks. Removed jwk-set-uri property. EspiTokenCustomizer RETAINED (not stripped): it is OAuth2TokenCustomizer<JwtEncodingContext> and currently inert (short-circuits unless espi.token.format=jwt), BUT it is the sole home of the ESPI logic adding resource/authorization URIs to the token. That logic must migrate to the opaque token-response path (#122 token-response augmentation), so the class + bean + test are kept deliberately. OIDC removal is a DEFERRAL, not permanent — OIDC returns when multi-utility Third-Party registration is built (#122). Data-custodian: replaced the misleading "Future enhancement: Add JWT support" comment with a note that JWT/JWK is intentionally absent (ESPI opaque-only). Tests: - AuthorizationServerConfigTest: removed the JWK Configuration test class + jwkSource()/ jwtDecoder() assertions (beans gone); espiTokenCustomizer assertions kept. - ClientRegistrationEndpointIntegrationTest: @disabled — every test hits the removed OIDC /connect/register endpoint. Restore when OIDC returns (#122); suite repair tracked in #129. - Blast radius is exactly that one class; OAuth2FlowIntegrationTest and SecurityIntegrationTest exercise only the opaque /oauth2/{authorize,token,introspect} + admin endpoints this change preserves. Verified (fresh MySQL, dev-mysql): - Boots clean (~37s) with NO JWKSource - POST /oauth2/token (client_credentials) -> 200 opaque token (128 chars, 0 dots) - POST /oauth2/introspect -> 200 RFC 7662 - wrong secret -> 401 - /.well-known/openid-configuration -> 404; /oauth2/jwks -> 302 (no key served) Known minor residue: the OAuth2 metadata doc still advertises a jwks_uri that now 302s (removing it needs a metadata customizer; harmless for opaque-only). Left as-is. Refs: #122 #128 #129 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
21 tasks
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
Closes #134. ESPI 4.0 uses opaque access tokens only and the GBA Resource Server carries no JWK/JWT (#122 constraint). The auth-server carried OIDC + JWK/JWT-signing machinery the opaque flow never exercises. This removes it. The opaque token mint + RFC 7662 introspection path is unchanged. +40 / −148 lines.
What changed
AuthorizationServerConfig.oidc(...)from the authorization-server configurer..oauth2ResourceServer().jwt(...)self-protection (added in fix(authserver): canonical Spring Security 7.x filter chain + Jackson modules on custom repo #128). The auth-server no longer bearer-protects its own endpoints — OAuth2 protocol endpoints (token/introspect/revoke) useclient_secret_basic; admin/UI endpoints use the@Order(2)session-login chain. (Decision pinned in the #122 design §5.)jwkSource()/jwtDecoder()beans,generateRsaKey(), the.jwkSetEndpoint()declaration, and all JWK/JWT imports.application.ymlOAuth2AuthorizationServerJwtAutoConfigurationso Spring Boot no longer auto-generates aJWKSource/ stands up/oauth2/jwks. Removed thejwk-set-uriproperty.EspiTokenCustomizer— RETAINED, not strippedOAuth2TokenCustomizer<JwtEncodingContext>and currently inert (short-circuits unlessespi.token.format=jwt), but it is the sole home of the ESPI logic that adds resource/authorization URIs to the token. That logic must migrate to the opaque token-response path (the Energy/Customer/Authorization URLs — #122 token-response augmentation). Class + bean + test kept deliberately. (Caught during review — initial instinct to delete it was wrong.)Data-custodian — replaced the misleading "Future enhancement: Add JWT support" comment in
SecurityConfigurationwith a note that JWT/JWK is intentionally absent.OIDC removal is a deferral, not permanent
OIDC returns when multi-utility Third-Party registration is built (#122). Code comments mark the re-entry point.
Tests
AuthorizationServerConfigTest: removed the JWK Configuration test class +jwkSource()/jwtDecoder()assertions (beans gone);espiTokenCustomizerassertions kept.ClientRegistrationEndpointIntegrationTest:@Disabled— every test hits the removed OIDC/connect/registerendpoint. Restore when OIDC returns; broader auth-server test-suite repair tracked in #129.OAuth2FlowIntegrationTestandSecurityIntegrationTestexercise only the opaque/oauth2/{authorize,token,introspect}+ admin endpoints this change preserves; the two TestContainers DB suites are unaffected.Verification (fresh MySQL container, dev-mysql)
POST /oauth2/token(client_credentials) → 200, 128-char opaque token (0 dots)POST /oauth2/introspect→ 200, RFC 7662 responsePOST /oauth2/tokenwrong secret → 401/.well-known/openid-configuration→ 404 (OIDC gone)/oauth2/jwks→ 302, no key served (was 200)Known minor residue
The OAuth2 metadata document still advertises a
jwks_urithat now 302s. Removing it requires a metadata customizer; harmless for opaque-only (nothing fetches jwks). Left as-is.Test plan
mvn -pl openespi-authserver test-compilesucceedsRelated
.jwt()self-protection from #128🤖 Generated with Claude Code