Reputation: 299
I found a tutorial about Spring REST Service OAuth on https://github.com/royclarkson/spring-rest-service-oauth
But I wonder how to configure client stored to database, so I can manage easily. In the tutorial client configuration store inMemory at class OAuth2ServerConfiguration.java
@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
}
Upvotes: 8
Views: 19304
Reputation: 299
@OhadR thank you for your answer, really appreciete it!
I acctually found the answer through this thread: error in Spring AuthorizationServerConfigurerAdapter when assigning Jdbc datastore to ClientDetailsService
To do this I only need two step:
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)
);
DataSource dataSource = DataSourceBuilder.create()
.driverClassName("com.mysql.jdbc.Driver")
.url("jdbc:mysql://localhost:3306/gsrestdb").username("***").password("***").build();
clients.jdbc(dataSource);
Upvotes: 9
Reputation: 8859
I believe that this is the answer that you are looking for:
This is Spring-oAuth Impl class for JDBC.
HTH
Upvotes: 1