小编sul*_*man的帖子

当使用Keyclaok进行POST请求时,Spring Boot返回403被禁止

我正在使用 Keycloak 来验证我的 Spring Boot 应用程序,

我已经与客户端(聊天系统)创建了一个新领域(CommonServices)

我有这个配置

keycloak:
  auth-server-url: http://localhost:8083/auth
  realm: CommonServices
  resource: chatting-system
  public-client: true
  principal-attribute: preferred_username
  use-resource-role-mappings: true
  security-constraints[0].authRoles[0]: user
  ssl-required: external

spring:
  data:
    mongodb:
      host: localhost
      port: 27017
      database: Chat
      username: saga
      password: password

  security:
    oauth2:
      resourceserver:
        jwt:
          jwk-set-uri: http://localhost:8083/auth/realms/CommonServices/protocol/openid-connect/certs
          issuer-uri: http://localhost:8083/auth/realms/CommonServices

Run Code Online (Sandbox Code Playgroud)

我已经配置了安全性:

@KeycloakConfiguration
class SecurityConfig extends KeycloakWebSecurityConfigurerAdapter {

    @Autowired
    public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
        KeycloakAuthenticationProvider keycloakAuthenticationProvider = keycloakAuthenticationProvider();
        auth.authenticationProvider(keycloakAuthenticationProvider);
    }

    @Bean
    @Override
    protected SessionAuthenticationStrategy sessionAuthenticationStrategy() {
        return new RegisterSessionAuthenticationStrategy(new SessionRegistryImpl());
    }

    @Override
    protected …
Run Code Online (Sandbox Code Playgroud)

java spring spring-boot keycloak

0
推荐指数
1
解决办法
4459
查看次数

标签 统计

java ×1

keycloak ×1

spring ×1

spring-boot ×1