【发布时间】:2014-08-28 11:40:00
【问题描述】:
我正在尝试将 OAuth 添加到我正在使用 Spring 框架开发的休息服务中。我正在使用基于注释的配置和 spring-boot 来让它运行。
我的项目中有以下课程:
@Configuration
@EnableWebSecurity
@Order(SecurityProperties.ACCESS_OVERRIDE_ORDER)
public class SecuritySettings extends WebSecurityConfigurerAdapter {
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.inMemoryAuthentication()
.withUser("admin").password("123").authorities("ROLE_USER");
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests().anyRequest().authenticated()
.and().httpBasic().and().csrf().disable();
}
}
而我的授权服务器配置如下:
@Configuration
@EnableAuthorizationServer
public static class MyAuthorizationServerConfiguration extends AuthorizationServerConfigurerAdapter {
@Override
public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
clients.inMemory().withClient("web")
.authorizedGrantTypes("password")
.authorities("ROLE_CLIENT","ROLE_TRUSTED_CLIENT","ROLE_USER")
.scopes("read", "write")
.resourceIds(RESOURCE_ID);
}
}
当我向/oauth/token/ 端点发出 GET 请求时,我被要求输入 HTTP 基本凭据。当我尝试使用admin 用户登录时,会记录以下内容
o.s.s.o.provider.endpoint.TokenEndpoint : Handling error: NoSuchClientException, No client with requested id: admin
输入用户名web 有效,但我不知道密码。记录了默认密码,但它也不起作用。
Using default security password: f23087f8-58ce-e3d-bc62-58bf0963e75c
那么这个密码是什么?我在哪里可以找到它?如何设置?
【问题讨论】:
标签: java spring-security oauth-2.0