最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

spring - How can I retrieve the configured oauth registrations in Springboot Oauth - Stack Overflow

programmeradmin5浏览0评论

I am using the OAuth client functionality in Spring Boot. Regarding customizing the login page, the documentation here:

.0.x/reference/html/oauth2login-advanced.html#oauth2login-advanced-login-page

says that I have to provide:

[...] a @Controller with a @RequestMapping("/login/oauth2") that is capable of rendering the custom login page.

I very much want to do this, but I cannot find a way to retrieve the registrations configured. I would need this in order to render the choices (or, to redirect to one if there is only one).

There is one "InMemoryClientRegistrationRepository" class, but it seems it might be less than ideal to depend on this, as there is nothing to guarantee that this is actually used.

Alternatively, I imagine the only way to do this would be to hop in here:

class OAuth2ClientRegistrationRepositoryConfiguration {

    @Bean
    @ConditionalOnMissingBean(ClientRegistrationRepository.class)
    InMemoryClientRegistrationRepository clientRegistrationRepository(OAuth2ClientProperties properties) {
        List<ClientRegistration> registrations = new ArrayList<>(
                new OAuth2ClientPropertiesMapper(properties).asClientRegistrations().values());
        return new InMemoryClientRegistrationRepository(registrations);
    }

}

and implement my own ClientRegistrationRegistry.

Did I miss any obvious ways to achieve this?

thanks

.rm

发布评论

评论列表(0)

  1. 暂无评论