<div dir="ltr"><div><div><div><div><div>I'm trying to configure keycloak with a spring boot application.<br><br></div>I followed the adapter configuration steps for open id. I'm able to get authentication working. I have the following dependencies:<br><br> <dependency><br> <groupId>org.springframework.boot</groupId><br> <artifactId>spring-boot-starter-security</artifactId><br> </dependency><br> <dependency><br> <groupId>org.keycloak</groupId><br> <artifactId>keycloak-spring-boot-adapter</artifactId><br> <version>${keycloak.version}</version><br> </dependency><br> <dependency><br> <groupId>org.keycloak</groupId><br> <artifactId>keycloak-tomcat8-adapter</artifactId><br> <version>${keycloak.version}</version><br> </dependency><br><br> ...<br><br> <keycloak.version>2.2.0.Final</keycloak.version><br><br>I have the following application properties:<br><br>security.basic.enabled=false<br><br>keycloak.realm=TestRealm<br>keycloak.realmKey=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAkz/W3jWdRGrRtklEldftShutJOy+WFhf2Kd7uPqk1F4ABs2RlTDOBWItW7j6zLAEuqOJIU1YLR8rwcW82/z3sUNblehP6nPH3ciZoBAn6THO/pB/BJ4Tq/oQ1GC0oYBb9kTQa3Aq7AQWkcpPVFGa70gaRZfeDk6GeucBa45PpHZgg+6YnGuCAJOi2SEkJBBJmXQyQtFvEtK2nIcche7WjXYIA/Eu/Aaz/b55OwFlxYbKxr6UQClGV+TZQsnVwbNdJMFH9ysrl6tAtROa38e/+ScoODh1CH0I2x6PEmB04bV4bx8iaXLwJotioRb/4xMMsx/+EBXYwd1o0Nw2OazksQIDAQAB<br>keycloak.auth-server-url=<a href="http://172.17.0.2:8080/auth">http://172.17.0.2:8080/auth</a><br>keycloak.ssl-required=external<br>keycloak.resource=test-client<br>keycloak.credentials.secret=e215d192-b9c9-4ebb-86e0-e0b46d21825c<br><br>keycloak.securityConstraints[0].securityCollections[0].name = insecure stuff<br>keycloak.securityConstraints[0].securityCollections[0].authRoles[0] = user<br>keycloak.securityConstraints[0].securityCollections[0].patterns[0] = /kennel/ping<br><br></div>I've confirmed my service method:<br><br>@RestController<br>@RequestMapping("/kennel")<br>@Validated<br>public class Kennel {<br><br>...<br> @RequestMapping(value = "/ping", method = RequestMethod.GET)<br> public final String ping() {<br> return String.valueOf(SecurityContextHolder.<br> getContext().<br> getAuthentication());<br> }<br>...<br>}<br><br></div>Is only executed when a user with the "user" role logs in and fails with a 403 otherwise. However, when a valid user, with a correct role does login, the result is "null".<br><br></div>What do I need to change/add to get the context populating with an authentication object?<br><br></div>Thanks<br><div><div><div><br></div></div></div></div>