JWT Java client implementation RestTemplate - client

I have to implement client for service which is secured by JWT is there implementation of that (i prefer something like RestTemplate extention like OAuth2RestTemplate), maybe is somewere tutorial how to customize RestTemplate to implement JWT?

Related

Rest API Calling Using Feign Client Vs RestTemplate

I want to call an API of the Spring Boot application from the my MVC Spring application. Is Feign Client or RestTemplate better for this API call and Why is it better?

RestTemplate with client-certificates

I would like to use client-certificates to communicate between spring-boot applications. My problem is, that don't know how to configure RestTemplate to use a client-certificate to authenticate against the other application.
If possible i would prefer to solve this problem with the Spring Boot properties instead of writing code - but any solution is better then none.
You are looking to implement a two way SSL authentication. It will have to be supported by whatever ClientHttpRequestFactory is configured in your RestTemplate.
If you use Spring Boot defaults, that is standard javax.net stack, take a look at Spring Boot Client authentication demo. Apache HttpClient and other libraries might require a different setup.

Implement Streamlined Identity Flows with Spring Security

I'm trying to implement Google's Streamlined Identity Flows for authenticating users on Actioins on Google with Spring Boot and Spring Security (OAuth).
I already managed to implement Google-SignIn but the server side is missing. I could implement every endpoint myself but as with most security concerns I think that it's better to use tested and proved frameworks or components. Now I'm trying to figure out how to use Spring Security's OAuth authorization server functionality.
How to implement the authorization endpoint that lets users authenticate with their browser and respond an authentication token
How to implement the JWT token endpoint
Is it possible to leverage the possibilities of Spring OAuth for this or do I have to create a custom endpoint with #Controller / #RestController for example.
Are their any tutorials or documentations on how to implement such a service with Spring Security?

Spring boot, security starter and OAuth2 client

I'm using Spring Boot with web and security starter dependencies, and spring-security-oauth2. I'm trying to secure a REST API with a remote (Openstack Keystone) OAuth2 provider.
So far I've managed to correctly fetch an access_token but when it comes to getting the user information I get a 404 not found, as it seems that the OS provider expects the access_token to be provided in the request parameters.
I can't figure out how to persuade the OAuth2RestTemplate class to append the access_token to the security.oauth2.client.resource.user-info-uri endpoint.
Figured out that setting security.oauth2.client.client-authentication-scheme to query will make the RestTemplate append the access_token to the subsequent requests for user information.

Spring OAuth2 OAuth2RestTemplate and resource owner password

I'm trying to figure out how to have my Spring OAuth2Client use the resource own password scheme when authenticating to my Authorization server using Spring OAuth2. I don't get what the documentation states:
If you desparately need password grants to work from a Java client, then use the same mechanism to configure your OAuth2RestTemplate and add the credentials to the AccessTokenRequest (which is a Map and is ephemeral) not the ResourceOwnerPasswordResourceDetails (which is shared between all access tokens).
How do I do this? Since I'm building both the authorization server and the client my client is a trusted source and I do not need to go through the auth code flow.
I saw this answer: Spring Security Oauth2 - Adding credentials to the AccessTokenRequest
But, I'm not exactly clear how to achieve this so that I don't have to go through the redirect. Can you do this through a basic auth header?
Update:
I think I got it working
I create a ResourceOwnerPasswordResourceDetails and create a new ResourceOwnerPasswordAccessTokenProvider
Then get a token using the credentials and set the token in the injected oauth rest template.
OAuth2AccessToken token = accessTokenProvider.obtainAccessToken(details, request);
restTemplate.getOAuth2ClientContext().setAccessToken(token);
Is this correct?

Resources