prp*_*ptn 8 spring-security oauth-2.0 spring-security-oauth2
我在https://github.com/royclarkson/spring-rest-service-oauth上找到了关于Spring REST Service OAuth的教程
但我想知道如何配置存储到数据库的客户端,所以我可以轻松管理.在课程OAuth2ServerConfiguration.java中的教程客户端配置存储inMemory中
@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
}
Run Code Online (Sandbox Code Playgroud)
@OhadR感谢您的回答,真的很感激!
我通过这个线程实际找到了答案:在将Jdbc数据存储区分配给ClientDetailsService时,Spring AuthorizationServerConfigurerAdapter出错
要做到这一点,我只需要两步:
CREATE TABLE oauth_client_details (
client_id VARCHAR(256) PRIMARY KEY,
resource_ids VARCHAR(256),
client_secret VARCHAR(256),
scope VARCHAR(256),
authorized_grant_types VARCHAR(256),
web_server_redirect_uri VARCHAR(256),
authorities VARCHAR(256),
access_token_validity INTEGER,
refresh_token_validity INTEGER,
additional_information VARCHAR(4096),
autoapprove VARCHAR(256)
);
Run Code Online (Sandbox Code Playgroud)
DataSource dataSource = DataSourceBuilder.create()
.driverClassName("com.mysql.jdbc.Driver")
.url("jdbc:mysql://localhost:3306/gsrestdb").username("***").password("***").build();
clients.jdbc(dataSource);
Run Code Online (Sandbox Code Playgroud)
我相信这就是您正在寻找的答案:
这是 JDBC 的 Spring-oAuth Impl 类。
华泰
| 归档时间: |
|
| 查看次数: |
16541 次 |
| 最近记录: |