【发布时间】:2016-01-02 12:44:32
【问题描述】:
我尝试为休息应用程序添加安全性。
我配置了扩展 WebSecurityConfigurerAdapter 的类。
http.authorizeRequests().antMatchers("/rest/**").authenticated();
http.csrf().disable();
http.exceptionHandling().authenticationEntryPoint(authenticationEntryPoint);
http.formLogin().successHandler(authenticationSuccessHandler);
http.formLogin().failureHandler(authenticationFailureHandler);
我有一个 login.html,index.html,它在 index.html 中加载(通过 jquery)一些其他 html 文件。
我尝试使用 curl 访问服务
curl -i -X POST -d username=test -d password=test http://localhost:8080/rest/cities
我得到一个
HTTP/1.1 401 Unauthorized
所有带有休息的网址都是安全的,但我提供的用户名和密码应该是单词。
当我调试时,我看到我的类实现了具有方法 loadUserByUsername 的 UserDetailsService 永远不会被调用。
有些东西链接不正确。
【问题讨论】:
标签: spring spring-security spring-boot spring-restcontroller spring-rest