Spring / Spring CredHub Interview questions
How do you configure OAuth2 authentication for Spring CredHub?
Add the OAuth2 client-credentials properties alongside the CredHub URL, along with the spring-security-config and spring-security-oauth2-client dependencies:
spring: credhub: url: https://credhub.example.com:8844 oauth2: registration-id: credhub-client security: oauth2: client: registration: credhub-client: provider: uaa client-id: my-client-id client-secret: my-client-secret authorization-grant-type: client_credentials provider: uaa: token-uri: https://uaa.example.com/oauth/token
When Spring Boot sees a configured OAuth2 client registration for CredHub, it auto-configures a client-credentials token flow against UAA and attaches the resulting bearer token to every CredHub request, instead of relying on mutual TLS.
The registration-id under spring.credhub.oauth2 is what ties the two configuration blocks together — it tells Spring CredHub which entry under spring.security.oauth2.client.registration holds the actual client ID, secret, and grant type to use. This indirection is what lets an app keep several OAuth2 client registrations for different purposes side by side, while pointing CredHub specifically at the one meant for it.
More Related questions...