Class OAuthClientCimdAwareService

java.lang.Object
io.meeds.oauth2.server.service.OAuthClientCimdAwareService
All Implemented Interfaces:
org.springframework.security.oauth2.server.authorization.client.RegisteredClientRepository

@Primary @Component public class OAuthClientCimdAwareService extends Object implements org.springframework.security.oauth2.server.authorization.client.RegisteredClientRepository
A RegisteredClientRepository decorator that lazily resolves and registers CIMD (Client ID Metadata Document) clients directly inside findByClientId(String).

This is deliberately independent of Spring Security's internal filter chain / filter ordering: since findByClientId is the exact method every OAuth2 endpoint filter calls to resolve the client (authorization endpoint validation, the main authorization endpoint, token endpoint client authentication, introspection, etc.), performing the CIMD resolution here means it works no matter which filter calls it, in what order, or how Spring Security's internal filter wiring changes in future versions. This replaces the previous approach of trying to run CIMD registration in an AuthenticationProvider or a manually-ordered servlet Filter, both of which depended on winning a race against the framework's own client-lookup timing.

Marked Primary so this bean, not the plain OAuthClientStorage, is the one wired into OAuth2AuthorizationServerConfigurer. Direct injections of OAuthClientStorage by its concrete type elsewhere in the codebase are unaffected.

  • Constructor Details

    • OAuthClientCimdAwareService

      public OAuthClientCimdAwareService()
  • Method Details

    • save

      public void save(org.springframework.security.oauth2.server.authorization.client.RegisteredClient registeredClient)
      Specified by:
      save in interface org.springframework.security.oauth2.server.authorization.client.RegisteredClientRepository
    • findById

      public org.springframework.security.oauth2.server.authorization.client.RegisteredClient findById(String id)
      Specified by:
      findById in interface org.springframework.security.oauth2.server.authorization.client.RegisteredClientRepository
    • findByClientId

      public org.springframework.security.oauth2.server.authorization.client.RegisteredClient findByClientId(String clientId)
      Specified by:
      findByClientId in interface org.springframework.security.oauth2.server.authorization.client.RegisteredClientRepository