我有这个Spring websocket安全配置。我想通过控制台(终端)验证用户,而不是在浏览器中,但不知道如何执行此操作。
@Configuration
@EnableWebSecurity
public class SecurityConfig extends AbstractSecurityWebSocketMessageBrokerConfigurer {
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth.inMemoryAuthentication().withUser("tet").password("123").roles("USER", "ADMIN");
auth.inMemoryAuthentication().withUser("admin").password("123").roles("ADMIN");
auth.inMemoryAuthentication().withUser("dba").password("123").roles("DBA");
}
@Override
protected void configureInbound(MessageSecurityMetadataSourceRegistry messages) {
messages.simpDestMatchers("/chat/**").access("hasRole('ROLE_ADMIN')").anyMessage().authenticated();
}
}