<html><head></head><body>Hi there,<br><br>we are currently setting up keycloak (1.8.1.Final) with an application containing an embedded jetty (9.2.10.v20150310). <br>Following the guidelines in the documentation, we have managed to make the authentication redirect process work.<br><br>However when the request is redirected back to our jetty (with an successful authentication), the variable "principal" of <b>org.keycloak.adapters.jetty.core.JettyRequestAuthenticator</b> in line 274 of <b>org.keycloak.adapters.jetty.core.AbstractKeycloakJettyAuthenticator</b> is null. <br><br>We are not fully understanding the mechanism behind it, thus have difficulties understanding what we are doing wrong here. Following is our jetty embedded code. We assume that the problem must be within those lines.<br>Any help, insight or tip is highly appreciated!<br><br>Thank you,<br>Gregor <br><br><span style="white-space:pre;"> </span> <span style="white-space:pre;"> </span> ...<br><span style="white-space:pre;"> </span> <span style="white-space:pre;"> </span> final HandlerList handlers = new HandlerList();<br><br> KeycloakJettyAuthenticator keycloakAuthenticator = new KeycloakJettyAuthenticator();<br> AdapterConfig keycloakAdapterConfig = new AdapterConfig();<br> keycloakAdapterConfig.setRealm("realm");<br> keycloakAdapterConfig.setRealmKey("realmKEY");<br> keycloakAdapterConfig.setAuthServerUrl("http://localhost:8080/auth");<br> keycloakAdapterConfig.setSslRequired("none");<br> keycloakAdapterConfig.setResource("client");<br> keycloakAdapterConfig.setPublicClient(true);<br> keycloakAdapterConfig.setTokenStore("cookie");<br><br> keycloakAuthenticator.setAdapterConfig(keycloakAdapterConfig);<br><br> ConstraintSecurityHandler security = new ConstraintSecurityHandler();<br> server.setHandler(security);<br><br> Constraint constraint = new Constraint();<br> constraint.setName("auth");<br> constraint.setAuthenticate(true);<br> constraint.setRoles(new String[] { "user", "admin" });<br><br> ConstraintMapping mapping = new ConstraintMapping();<br> mapping.setPathSpec("/*");<br> mapping.setConstraint(constraint);<br><br> security.setConstraintMappings(Collections.singletonList(mapping));<br> security.setAuthenticator(keycloakAuthenticator);<br><br> handlers.addHandler(security);<br><br><br> ServletContextHandler servletHandler = new ServletContextHandler(security, "/*", ServletContextHandler.NO_SESSIONS);<br> handlers.addHandler(servletHandler);<br><span style="white-space:pre;"> </span> <span style="white-space:pre;"> </span> server.setHandler(handlers);<br> ...<br></body></html>