【发布时间】:2015-08-04 18:35:38
【问题描述】:
好吧,我有一个安全的休息服务,只是使用带有静态凭据“用户”和“密码”的 spring-security。当我使用其余服务时,会在浏览器上显示登录对话框,效果很好。
当我想使用使用 Spring 的 Web 应用程序来使用我的服务时,问题出现了,我不知道如何继续,我感谢任何解决方案,我是 Spring 的新手,我不知道不知道我是否必须在我的休息服务中添加一些方法,或者只有一种方法可以从 webapp 发送凭据。
这是我的休息服务的安全配置。
@Configuration
@Order(value = SecurityProperties.ACCESS_OVERRIDE_ORDER)
@EnableWebMvcSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
private AuthenticationProvider authenticationProvider;
protected void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth.authenticationProvider(authenticationProvider);
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests().anyRequest()
.fullyAuthenticated().and().formLogin().permitAll();
}
}
我正在尝试使用 Angular 服务来使用服务:
restwebapp.controller('restController', function($scope, Servicio){
Servicio.GetGreeting.get({}, function(response){
$scope.hello = response;
});
})
restwebapp.factory('Servicio', function($resource){
return{
GetGreeting: $resource( 'http://localhost:8080/greeting', {}, {
get:{
method:'GET',
}
})
}
})
该服务以 json 格式返回 fromlogin,是否有另一种方法可以对我的 rest 服务进行身份验证,或者有什么更好的方法。
提前致谢
【问题讨论】:
标签: java angularjs spring rest spring-security