[keycloak-user] Keycloak Spring Boot Adapter does not populate security context principal

Niels Bertram nielsbne at gmail.com
Tue Oct 31 08:25:46 EDT 2017


Hi Keycloak Users,

I tried to configure a dead simple Spring Boot CXF REST endpoint with
Keycloak Spring Boot Adapter in Bearer Only mode without any luck. It
appears the Keycloak Tomcat Valve fails authorization even before the
keycloak adapter ever gets a chance to parse the Bearer token and setup the
session. I would have thought that with AutoConfig it would just be that
... auto config. I added the below keycloak adapter configuration to the
application.yml file and made sure all required jars are on the classpath.

Does anyone have any suggestions or a link to a working example that shows
how to use Spring Boot with Keycloak *AND* CXF ?

Many thanks, Niels

Example:

https://github.com/bertramn/keycloak-secured-rest-endpoint


application.yml configuration:


keycloak:
  realm: demo
  authServerUrl: 'http://localhost:8080/auth'
  realmKey: 'MIIBIjANBgDAQAB'
  sslRequired: external
  resource: test-client
  bearerOnly: true
  securityConstraints:
    - authRoles: [ '*' ]
      securityCollections:
        - name: authed
          patterns: [ '/v1/secured' ]


More information about the keycloak-user mailing list