Я использую свою собственную реализацию ClientDetailsServiceConfigurer
так я делаю так:Как загрузить клиентскими по ClientId И ClientSecret - OAuth 2.0
OAuthConfig.java
@Override
public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
clients.withClientDetails(this.customClientDetailsManager);
}
CustomClientDetailsManager.java
@Service
public class CustomClientDetailsManager implements ClientDetailsService {
final static Logger log = LoggerFactory.getLogger(CustomClientDetailsManager.class);
private final CustomerService customerService;
@Inject
public CustomClientDetailsManager(final CustomerService customerService) {
this.customerService = customerService;
}
@Override
public ClientDetails loadClientByClientId(String clientId) throws ClientRegistrationException {
final Customer customer = customerService.getCustomerByClientId(clientId);
log.debug("****** Customer is: " + customer.getClientId());
log.debug("****** Customer Secret is: " + customer.getClientSecret());
log.debug("****** Client ID Coming from Request is: " + clientId);
final BaseClientDetails details = new BaseClientDetails();
details.setClientId(clientId);
log.debug("*** Client id: " + clientId);
details.setAuthorizedGrantTypes(Arrays.asList(customer.getAuthorizedGrantTypes()));
log.debug("*** AuthorizedGrantTypes: " + Arrays.asList(customer.getAuthorizedGrantTypes()));
details.setScope(Arrays.asList(customer.getScope()));
log.debug("*** Scope: " + Arrays.asList(customer.getScope()));
details.setResourceIds(Arrays.asList(customer.getResourceIds()));
log.debug("*** ResourceIds: " + Arrays.asList(customer.getResourceIds()));
final Set<GrantedAuthority> authorities = new HashSet<GrantedAuthority>();
authorities.add(new SimpleGrantedAuthority(customer.getAuthorities()));
details.setAuthorities(authorities);
authorities.forEach(authority -> {
log.debug("*** Authority: " + authority);
});
log.debug("Returning details...");
return details;
}
Так что в основном я хватаю свой ClientId
через loadClientByClientId(String clientId)
, но мне нужен метод, который позволяет мне захватить мой идентификатор клиента и секрет клиента.
Любые подсказки? Спасибо