我正在使用 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)