Spring 云配置安全

问题描述 投票:0回答:1

我做了一个经典的授权是spring cloud config server这样的:

http.csrf().disable()
            .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.ALWAYS)
            .and()
            .authorizeRequests()
            .anyRequest().authenticated()
            .and()
            .formLogin()
            .loginPage("/login")
            .defaultSuccessUrl("/", true).permitAll();

现在我尝试使用密码和用户名从我的客户端应用程序访问道具,但它不起作用。有没有一种方法可以使用这种类型的安全性进行连接,还是应该是基本的?

错误看起来像这样:

Could not extract response: no suitable HttpMessageConverter found for response type [class org.springframework.cloud.config.environment.Environment] and content type [text/html;charset=UTF-8]

如果我在服务器上退回授权,它不会重现

java spring spring-cloud spring-cloud-config
1个回答
0
投票

你收到什么错误?你能补充你的问题吗?

你需要像这个例子一样定义一个 Bean:

@Bean
public UserDetailsService users() {
UserDetails user = User.builder()
    .username("user")
    .password("{bcrypt}$2a$10$GRLdNijSQMUvl/au9ofL.eDwmoohzzS7.rmNSJZ.0FxO/BTk76klW")
    .roles("USER")
    .build();
UserDetails admin = User.builder()
    .username("admin")
    .password("{bcrypt}$2a$10$GRLdNijSQMUvl/au9ofL.eDwmoohzzS7.rmNSJZ.0FxO/BTk76klW")
    .roles("USER", "ADMIN")
    .build();
return new InMemoryUserDetailsManager(user, admin);

}

您是否尝试进行 http REST 调用? 在错误中,它看起来像是来自环境类型的响应。 为什么你需要访问这样的道具?

© www.soinside.com 2019 - 2024. All rights reserved.