ClientDetailsS​​ervice和InMemory客户端身份验证

时间:2019-02-12 09:53:58

标签: java spring spring-security spring-security-oauth2

我正在编写一个oauth2授权服务器,该服务器应支持两种身份验证。

  1. 使用带有固定clientId的用户名和密码(授予密码)进行身份验证
  2. 使用其中cliendIdclientSecret存储在数据库中的预注册应用进行身份验证

我的配置如下。

@Override
    public void configure(ClientDetailsServiceConfigurer configurer) throws Exception {
        configurer
                // registered apps 
                .withClientDetails(appClientDetailsService)
               // user auth
        .and().inMemory()
                .withClient(clientId)
                .secret(clientSecret)
                .authorizedGrantTypes(grantType)
                .scopes(scopeRead, scopeWrite)
                .resourceIds(resourceIds);
}

两者都是靠自己工作的,但是如果我将它们结合在一起(and()),则会收到错误消息:

IllegalStateException: securityBuilder cannot be null

是否可以使用ClientDetailsService和硬编码的inMemory客户端,还是需要将UserAuthClient添加到数据库中?

谢谢

0 个答案:

没有答案