Spring Boot在AuthorizationServerConfigurerAdapter中配置ClientDetailsS​​erviceConfigurer - oAuth2

时间:2015-07-20 19:10:41

标签: spring-security spring-boot

我正在努力使用Spring Boot。我在git hub上找到了很棒的项目,我正在把事情放在一起,以了解正在发生的事情。我有这段代码,我不明白在做什么:

@Override
    public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
        // @formatter:off
        clients
            .inMemory()
                .withClient("clientapp")
                    .authorizedGrantTypes("password", "refresh_token")
                    .authorities("USER")
                    .scopes("read", "write")
                    .resourceIds(RESOURCE_ID)
                    .secret("123456");
        // @formatter:on
    }

我用inMemory()定义了什么?和凯特等等......我不明白,我需要一些解释。

1 个答案:

答案 0 :(得分:10)

Oauth2针对用户信息的某些访问类型对客户端应用进行身份验证。

在您的示例中,它配置名为clientapp的客户端应用。

inMemory表示创建会话的所有必要数据都将存储在内存中。当您重新启动应用程序时,所有会话数据都将消失,这意味着用户需要再次登录和验证。

授权类型表示客户端应用程序对用户信息的权限。在这种情况下,客户端应用程序有权读取和写入用户的passwordrefresh_token

如果您想了解更多信息,可以查看this教程。你也应该知道oAuth2是什么。