0

I'd like to move away from the keycloak adapters as they will be deprecated in the long run. Unfortunately I cannot figure out how to do this after >1d of work. I created a minimal not working example here. I have the issue that

  1. The Login with OAuth 2.0 page is empty although everything is present in the application.yaml
  2. I'd like to get automatically redirected to Keycloak. Just like the normal adapter.

The minimal working example contains an endpoint /hello that is secured by spring boot security. The goal is to authenticate with Keycloak and then navigate to this url. If this configuration also works in applications like Postman that would be awesome.

Here are pictures of the keycloak configuration (It worked previously with the adapter): Client General settings Client Secret Page

Update: I managed to get the resource server working but the client seems to be inactive.

SamTV
  • 147
  • 1
  • 11
  • can you check this example, maybe you missed a configuration. https://www.analyticsvidhya.com/blog/2022/06/spring-security-oauth2-with-keycloak/ – muhammed ozbilici Nov 25 '22 at 22:23

1 Answers1

1

Your sample controller is a @RestController => your application is a resource-server but you're trying to configure it as a client (that won't work).

Refer to this answer for detailed solution: https://stackoverflow.com/a/74572732/619830

ch4mp
  • 6,622
  • 6
  • 29
  • 49
  • What if my spring application contains multiple interfaces? 1 Frontend with e.g. JSF, 1 backend with a REST-API and a REST-Template which accesses keycloak? Do I need to implement at least 2 of them and how would that look like? – SamTV Nov 26 '22 at 09:02
  • 1
    I have updated the answer linked to add a "client" filter-chain to the "resource-server" one. That will answer your question about JSF UI. Just define a client with client-credentials flow in properties file for your REST client. – ch4mp Nov 28 '22 at 04:02