Я использую OAuth2 с Spring и безуспешно пытаюсь использовать конфигурацию из базы данных.
Если я это сделаю:
@Override
public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
clients.inMemory().withClient("clients").secret(encriptar.passwordEncoder().encode("1234"))
.authorizedGrantTypes("password", "refresh_token", "authorization_code").scopes("read,write,trust")
.accessTokenValiditySeconds(5).refreshTokenValiditySeconds(28800);
}
все отлично работает
Но если я попробую:
@Override
public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
clients.jdbc(dataSource).passwordEncoder(encriptar.passwordEncoder());
}
Когда я пытаюсь получить доступ к конечной точке / oauth / token,
Я получаю ошибку
{
"error": "unauthorized",
"error_description": "Full authentication is required to access this resource"
}
мои настройки:
@Table(name = "oauth_client_details")
public class Token {
@Id
private String client_id;
private String cliente_secret;
private String resource_ids;
private String scope;
private String authorized_grant_types;
private String web_server_redirect_uri;
private String authorities;
private String access_token_validity;
private String refresh_token_validity;
private String additional_information;
private String autoapprove;
}
# # # #
@Bean
public OAuth2RequestFactory requestFactory() {
CustomOauth2RequestFactory requestFactory = new CustomOauth2RequestFactory(clientDetailsService);
requestFactory.setCheckUserScopes(true);
return requestFactory;
}
@Bean
public TokenStore tokenStore() {
return new JwtTokenStore(jwtAccessTokenConverter());
}
@Bean
public TokenEndpointAuthenticationFilter tokenEndpointAuthenticationFilter() {
return new TokenEndpointAuthenticationFilter(authenticationManager, requestFactory());
}
Что я делаю не так?