Spring Security,Keycloak:获取OAuth2提供程序信息

问题描述

我有一个用Keycloak固定的Spring-Rest-Server。因此,我(成功地)使用Keycloak将Spring Server配置为OAuth2提供程序:

@Override
    public void configure(HttpSecurity http) throws Exception {
        http
                .authorizeRequests()
                    .antMatchers("/api/data").permitAll()
                    .antMatchers("/api/account").permitAll()
                    .antMatchers("/api/logout").authenticated()
                    .antMatchers("/api/restricted/**").authenticated()
                    .antMatchers("/api/admin/**").hasRole("ADMIN")
                .and()
                    .oauth2Login()
                    .defaultSuccessUrl("http://localhost:8081")
                .and()
                    .oauth2ResourceServer()
                    .jwt()
                    .and()
                .and()
                    .oauth2client();

到目前为止,我是通过将用户重定向

来从JS-Frontend调用登录到keycloak的。

http:// keycloakInstance / auth / realms / myRealm / protocol / openid-connect / auth?response_type = code&client_id = web_app&redirect_uri =

这是可行的,但是对于此流程,我的GUI已经需要知道keycloak-instance的URL。有谁知道如何“询问” Spring-Server,在哪里找到其Auth-Provider?

我在想我的restserver上必须有一个端点,该端点告诉GUI,要进行身份验证并获取access_token的URL是什么。 这个端点是什么?仅知道Spring服务器,我有什么可能要求Auth-Server?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)