spring-cloud-security icon indicating copy to clipboard operation
spring-cloud-security copied to clipboard

How to get a client_credentials token for doing behind the scenes calls

Open leon opened this issue 10 years ago • 6 comments

If I inject the the bean registered as oAuth2RestTemplate it will pass on the user token.

If I want to pass on a client_credential would it be correct to do this?

@Bean
@ConfigurationProperties("spring.oauth2.client")
public ClientCredentialsResourceDetails oauth2ClientCredentialsResourceDetails() {
    ClientCredentialsResourceDetails details = new ClientCredentialsResourceDetails();
    return details;
}

@Bean
public OAuth2RestTemplate clientCredentialsRestTemplate(OAuth2ClientContext oauth2ClientContext, ClientCredentialsResourceDetails details) {
    OAuth2RestTemplate template = new OAuth2RestTemplate(details, oauth2ClientContext);
    return template;
}

Maybe we should add a section in the docs about machine to machine communication and how to do that with feign or with RestTemplate?

leon avatar Apr 01 '15 07:04 leon

Sounds like a plan. See also #51.

dsyer avatar Apr 01 '15 09:04 dsyer

@dsyer I would also like to use use OAuth2 for backend requests such as requests to the config server and service register (Eureka). What is the best approach to ensure client credentials are used within the discovery client and config client?

jjparsons avatar May 15 '16 16:05 jjparsons

I sincerely hope you guys fix this problem.I just want to secure my spring cloud application.Did it get fixed?

geercode avatar Dec 27 '17 09:12 geercode

It's not a problem is it? Just a documentation request. What do you mean? How would you "fix" it?

dsyer avatar Dec 27 '17 10:12 dsyer

ping @JerryNiu

spencergibb avatar Jan 17 '18 23:01 spencergibb

Easy,guys.Last time I check this was at version D.When I use thread strategy,It cant pass client credentials in the header.I was not looking into it for a detail.No offence. @dsyer @spencergibb

geercode avatar Aug 29 '18 04:08 geercode