How to integrate keycloak on a simple spring boot example

I have the following simple example of a spring boot API that I’m testing with keycloak that was made based on THIS EXAMPLE but no matter what I do it doesn’t work. When I make the request to the protected endpoint nothing happens, no logs, nothing.
What am I missing here ?

Did you tried it with Spring Security?

No, but I believe that it should work like that, no?

Besides, does spring security have any advantage?

The keycloak starter pulls in Spring Security so you’re already using it.
Maybe you should create a git repo and share the link here so people can take a look at it instead of posting a couple of files.
I don’t see the secret you’re using in the keycloak-config.json for starters or you replaced them with stars for which there is no point as you share you’re secret in the application.yml file.
You should also take a look on how to configure securityConstraints correctly as you’re config seems to contradict what your controller tries to do.

1 Like

@zonaut, thanks for the reply.
I didn’t created a repo because this was supposed to be an EXTREMELY simple api just for tests. But you’re right, I’m going to present a better example.

The keycloak-config.json was automatically generated on keycloak export, I haven’t edited it’s content.

It’s weird but the * securityConstraints* it’s just like it was supposed to be (trying to protect
what was supposed to be the public endpoint :smile: , it was some tests I was doing and I forgot to fix it).