<html><head><style type='text/css'>p { margin: 0; }</style></head><body><div style='font-family: times new roman,new york,times,serif; font-size: 12pt; color: #000000'><div style="color: rgb(0, 0, 0); font-family: &quot;times new roman&quot;, &quot;new york&quot;, times, serif; font-size: 12pt;">Additional info to make my case cleared. This is what I get from my targeted microservice process log:</div><div><div><font face="times new roman, new york, times, serif">org.keycloak.common.VerificationException: Token audience doesn't match domain. Token issuer is</font></div><div><font face="times new roman, new york, times, serif">&nbsp;http://slaveKCInstance.ourcompanyname.com:8230/auth/realms/SearchMicroservices,&nbsp;</font></div><div><font face="times new roman, new york, times, serif">but URL from configuration is http://masterKCInstance.ourcompanyname.com:8230/auth/realms/SearchMicroservices</font></div><div><font face="times new roman, new york, times, serif"><span class="Apple-tab-span" style="white-space:pre">        </span>at org.keycloak.RSATokenVerifier.verifyToken(RSATokenVerifier.java:49)</font></div><div><font face="times new roman, new york, times, serif"><span class="Apple-tab-span" style="white-space:pre">        </span>at org.keycloak.RSATokenVerifier.verifyToken(RSATokenVerifier.java:35)</font></div><div><font face="times new roman, new york, times, serif"><span class="Apple-tab-span" style="white-space:pre">        </span>at org.keycloak.adapters.BearerTokenRequestAuthenticator.authenticateToken(BearerTokenRequestAuthenticator.java:87)</font></div><div><font face="times new roman, new york, times, serif"><span class="Apple-tab-span" style="white-space:pre">        </span>at org.keycloak.adapters.BearerTokenRequestAuthenticator.authenticate(BearerTokenRequestAuthenticator.java:82)</font></div><div><font face="times new roman, new york, times, serif"><span class="Apple-tab-span" style="white-space:pre">        </span>at org.keycloak.adapters.RequestAuthenticator.authenticate(RequestAuthenticator.java:65)</font></div><div><font face="times new roman, new york, times, serif"><span class="Apple-tab-span" style="white-space:pre">        </span>at org.keycloak.adapters.springsecurity.filter.KeycloakAuthenticationProcessingFilter.attemptAuthentication(KeycloakAuthenticationProcessingFilter.java:137)</font></div><div><font face="times new roman, new york, times, serif"><span class="Apple-tab-span" style="white-space: pre;">        </span>at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:217)</font></div></div><div style="color: rgb(0, 0, 0); font-family: &quot;times new roman&quot;, &quot;new york&quot;, times, serif; font-size: 12pt;"><br></div><div style="color: rgb(0, 0, 0); font-family: &quot;times new roman&quot;, &quot;new york&quot;, times, serif; font-size: 12pt;">Do I need to change the configuration of my SecurityConfig class(<span style="font-size: 12pt;">&nbsp;which has the current &nbsp;implementation as public class SecurityConfig extends KeycloakWebSecurityConfigurerAdapter)?</span></div><div style="color: rgb(0, 0, 0); font-family: &quot;times new roman&quot;, &quot;new york&quot;, times, serif; font-size: 12pt;">Thanks,</div><div style="color: rgb(0, 0, 0); font-family: &quot;times new roman&quot;, &quot;new york&quot;, times, serif; font-size: 12pt;">ioan</div><br><hr id="zwchr" style="color: rgb(0, 0, 0); font-family: &quot;times new roman&quot;, &quot;new york&quot;, times, serif; font-size: 12pt;"><div style="color: rgb(0, 0, 0); font-family: Helvetica, Arial, sans-serif; font-size: 12pt; font-weight: normal; font-style: normal; text-decoration: none;"><b>From: </b>"i pop" &lt;i.pop@centurylink.net&gt;<br><b>To: </b>stian@redhat.com<br><b>Cc: </b>"keycloak-user" &lt;keycloak-user@lists.jboss.org&gt;<br><b>Sent: </b>Thursday, September 22, 2016 1:45:55 PM<br><b>Subject: </b>Re: [keycloak-user] Setting up a Keycloak Domain Cluster<br><br><style>p { margin: 0; }</style><div style="font-family: times new roman,new york,times,serif; font-size: 12pt; color: #000000"><br><font face="times new roman, new york, times, serif"><span style="font-size: 12pt;">Thank you &nbsp;Stian for your message. I have gotten the &nbsp;cluster working in the domain mode(just two nodes: master&amp;slave):</span></font><div><font face="times new roman, new york, times, serif">MASTER NODE LOG:<br></font><div><div><font face="times new roman, new york, times, serif">[Server:server-one] 12:33:37,761 INFO &nbsp;[org.infinispan.remoting.transport.jgroups.JGroupsTransport] (Incoming-2,ee,master:server-one) ISPN000094: Received new cluster view for channel server: [master:server-one|1] (2) [master:server-one, slave1:server-two]</font></div><div><div style="color: rgb(0, 0, 0); font-family: &quot;times new roman&quot;, &quot;new york&quot;, times, serif; font-size: 12pt;">[Server:server-one] 12:33:38,411 INFO &nbsp;[org.infinispan.CLUSTER] (remote-thread--p8-t6) ISPN000310: Starting cluster-wide rebalance for cache realms, topology CacheTopology{id=1, rebalanceId=1, currentCH=ReplicatedConsistentHash{ns = 60, owners = (1)[master:server-one: 60]}, pendingCH=ReplicatedConsistentHash{ns = 60, owners = (2)[master:server-one: 30, slave1:server-two: 30]}, unionCH=null, actualMembers=[master:server-one, slave1:server-two]}</div><div style="color: rgb(0, 0, 0); font-family: &quot;times new roman&quot;, &quot;new york&quot;, times, serif; font-size: 12pt;">[Server:server-one] 12:33:38,419 INFO &nbsp;[org.infinispan.CLUSTER] (remote-thread--p8-t4) ISPN000336: Finished cluster-wide rebalance for cache users, topology id = 1</div><div style="color: rgb(0, 0, 0); font-family: &quot;times new roman&quot;, &quot;new york&quot;, times, serif; font-size: 12pt;"></div><div style="color: rgb(0, 0, 0); font-family: &quot;times new roman&quot;, &quot;new york&quot;, times, serif; font-size: 12pt;"><span style="font-size: medium;">SLAVE NODE LOG:</span></div><div><div><font face="times new roman, new york, times, serif">[Server:server-two] 12:33:38,179 INFO &nbsp;[org.infinispan.remoting.transport.jgroups.JGroupsTransport] (MSC service thread 1-6) ISPN000094: Received new cluster view for channel server: [master:server-one|1] (2) [master:server-one, slave1:server-two]</font></div><div style="color: rgb(0, 0, 0); font-family: &quot;times new roman&quot;, &quot;new york&quot;, times, serif; font-size: medium;"></div></div></div><div style="color: rgb(0, 0, 0); font-family: &quot;times new roman&quot;, &quot;new york&quot;, times, serif; font-size: medium;">THE ISSUE IS NOW how to test this working cluster.It looks like the the content of the Keycloak string pattern generated by the master's Keycloak instance( and &nbsp;added to each microservice's &nbsp;keycloak.json file) &nbsp;HAS NOT CHANGED : I still get &nbsp;the same "auth-server-url" info &nbsp;as before when I had &nbsp;was not working cluster; no reference to the the other node members of the working cluster :</div><div><div style="color: rgb(0, 0, 0); font-family: &quot;times new roman&quot;, &quot;new york&quot;, times, serif; font-size: medium;">{</div><div style="color: rgb(0, 0, 0); font-family: &quot;times new roman&quot;, &quot;new york&quot;, times, serif; font-size: medium;">&nbsp; "realm": "SearchMicroservices",</div><div style="color: rgb(0, 0, 0); font-family: &quot;times new roman&quot;, &quot;new york&quot;, times, serif; font-size: medium;">&nbsp; "realm-public-key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAh",</div><div style="color: rgb(0, 0, 0); font-family: &quot;times new roman&quot;, &quot;new york&quot;, times, serif; font-size: medium;">&nbsp; "auth-server-url": "http://masterKCInstance.ourcompanyname.com:8230/auth",</div><div style="color: rgb(0, 0, 0); font-family: &quot;times new roman&quot;, &quot;new york&quot;, times, serif; font-size: medium;">&nbsp; "ssl-required": "external",</div><div style="color: rgb(0, 0, 0); font-family: &quot;times new roman&quot;, &quot;new york&quot;, times, serif; font-size: medium;">&nbsp; "resource": "LDAPSearch-Microservice",</div><div style="color: rgb(0, 0, 0); font-family: &quot;times new roman&quot;, &quot;new york&quot;, times, serif; font-size: medium;">&nbsp; "credentials": {</div><div style="color: rgb(0, 0, 0); font-family: &quot;times new roman&quot;, &quot;new york&quot;, times, serif; font-size: medium;">&nbsp; &nbsp; "secret": "235b2960-1b6f-48bd-a5c4-069b5fc5cc16"</div><div style="color: rgb(0, 0, 0); font-family: &quot;times new roman&quot;, &quot;new york&quot;, times, serif; font-size: medium;">&nbsp; },</div><div style="color: rgb(0, 0, 0); font-family: &quot;times new roman&quot;, &quot;new york&quot;, times, serif; font-size: medium;">&nbsp; "use-resource-role-mappings": true</div><div style="color: rgb(0, 0, 0); font-family: &quot;times new roman&quot;, &quot;new york&quot;, times, serif; font-size: medium;">}</div><div style="color: rgb(0, 0, 0); font-family: &quot;times new roman&quot;, &quot;new york&quot;, times, serif; font-size: medium;"><br></div><div style="color: rgb(0, 0, 0); font-family: &quot;times new roman&quot;, &quot;new york&quot;, times, serif; font-size: medium;">If &nbsp;I stop the Keycloak instance running on the master node(from the WildFly management interface) and, I send a client search request message to one of my running application registered in the realm as clients, I was expecting the request to be be &nbsp;redirected &nbsp;by the load-balancer to the running state slave Keycloak instance (node: "http://slaveKCInstance.ourcompanyname.com:8230/auth"); get a valid access_token from it ,then my client request message(along with generated bearer token) sent &nbsp;to my targeted &nbsp;resource should &nbsp;get a a response message. It does not happen like this.What I get is this :</div><div><font face="times new roman, new york, times, serif">{"path":"\/v1\/ldap\/DBResource\/resourceName","error":"Unauthorized","message":"Unable to authenticate bearer token","timestamp":1474566606034,"status":401}</font></div></div><div><font face="times new roman, new york, times, serif"></font></div><div><font face="times new roman, new york, times, serif">The same outcome as described in my initial message sent to you. Can you please tell me what is wrong in my testing procedure?</font></div><div><font face="times new roman, new york, times, serif">Thanks,</font></div><div><font face="times new roman, new york, times, serif">Ioan</font></div><div style="color: rgb(0, 0, 0); font-family: &quot;times new roman&quot;, &quot;new york&quot;, times, serif; font-size: medium;">&nbsp;&nbsp;</div><hr id="zwchr" style="color: rgb(0, 0, 0); font-family: &quot;times new roman&quot;, &quot;new york&quot;, times, serif; font-size: 12pt;"><div style="color: rgb(0, 0, 0); font-family: Helvetica, Arial, sans-serif; font-size: 12pt; font-weight: normal; font-style: normal; text-decoration: none;"><b>From: </b>"Stian Thorgersen" &lt;sthorger@redhat.com&gt;<br><b>To: </b>"i pop" &lt;i.pop@centurylink.net&gt;<br><b>Cc: </b>"keycloak-user" &lt;keycloak-user@lists.jboss.org&gt;<br><b>Sent: </b>Tuesday, September 20, 2016 3:03:09 AM<br><b>Subject: </b>Re: [keycloak-user] Setting up a Keycloak Domain Cluster<br><br><div dir="ltr">Doesn't sound like you have working clustering setup. Please take a look at&nbsp;<a href="https://keycloak.gitbooks.io/server-installation-and-configuration/content/topics/clustering.html" target="_blank">https://keycloak.gitbooks.io/server-installation-and-configuration/content/topics/clustering.html</a>.</div><div class="gmail_extra"><br><div class="gmail_quote">On 18 September 2016 at 04:15, <a href="mailto:i.pop@centurylink.net" target="_blank">i.pop@centurylink.net</a> <span dir="ltr">&lt;<a href="mailto:i.pop@centurylink.net" target="_blank">i.pop@centurylink.net</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div style="font-family:times new roman,new york,times,serif;font-size:12pt;color:#000000">Hi ,<div>I work on POC to use Keycloak to secure a set of microservices( java written SpringBooth&amp;gradle projects).</div><div>I use Keycloak-2.1.0.Final release installed on 3 different VMs(master running on VM1, slave1 on VM2, slave2 on VM2). <span style="font-size:12pt">On a 4th VM I have installed a shared (MySql) db to replace the embedded H2 db.</span></div><div><span style="font-size:12pt">I have configured a Keycloak Domain Mode cluster using keycloak documentation "Server Installation and Configuration Guide".</span></div><div></div><div>1. I have logged on the master keycloak server and configured my new Realm that has my microservice processes &nbsp;as clients.I have added roles,users,groups, etc., The realm configuration of the master keycloak instance &nbsp;got replicated on the slave instances ( I can see the cluster running when loging-on &nbsp;WildFly Management Interface).</div><div>2. I have added to all microservice java projects the &nbsp;keycloak securing code:&nbsp;</div><div>&nbsp; &nbsp; 2.1 Created a keycloak.json file who's content was generated my the MASTER keycloak server(Client's "Installation" utility)</div><div>&nbsp; &nbsp; 2.2 Added to the &nbsp;project's Application class a &nbsp;system property, to target the keycloak.json file generated by the MASTER keycloak &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; instance:<span style="font-size:12pt">System.setProperty("keycloak.configurationFile", "classpath:keycloak.json");</span></div><div>&nbsp; &nbsp; 2.3 Created a new config's package class : public class SecurityConfig extends KeycloakWebSecurityConfigurerAdapter</div><div>&nbsp; &nbsp; 2.4 &nbsp;Added to the build.gradle file keycloak spring security adapter compilation :&nbsp;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;compile group: 'org.keycloak', name:'keycloak-spring-security-adapter',version:'2.1.0.Final</div><div>&nbsp; Note. I have compared the content of the json format code generated by the Client "Installation" utility of the slave instances against master instance and, THE ONLY DIFFERENCE is the<b> "auth-server-url"</b> line (having the specific node URL address)&nbsp;</div><div>3. Now, I want to do the test of accessing particular resources of my microservice applications(additional info: I did not implemented any load-balancer in front of the keycloak cluster):&nbsp;</div><div>&nbsp; &nbsp; &nbsp;I have created a simple java program that uses a Basic Authorization &nbsp;procedure to get an access token, and then use this token to sent request messages to my microservice application and get the expected response messages.</div><div>&nbsp; &nbsp;- When I use the MASTER's instance authorization endpoint to get an access token, I get the expected response message( because, I presume, &nbsp;my microservice application attached &nbsp;keycloak.json file has HARDCODED content &nbsp;generated by the MASTER's instance &amp; containing MASTERS's authorization endpoint).</div><div>&nbsp; &nbsp; - When I use either-one SLAVE keycloak instance authorization&amp;token generation endpoint to generate an access token, my request &nbsp;fails with a 401 error:<span style="font-size:12pt">"Unable to authenticate bearer token"</span></div><div>I believe or feel, I use a wrong approach to solve my problem. My microservice applications (at this time) &nbsp;DO NOT KNOW anything, whether I use a domain mode cluster &nbsp;or, a simple standalone keycloak instanceattached keycloak.json file has ONLY one keycloak instance (<span style="font-size:12pt">MASTER's</span><span style="font-size:12pt">&nbsp;)</span><span style="font-size:12pt">&nbsp;&nbsp;"auth-server-url" &nbsp;info ).</span></div><div>Here, I need your help to enlighten me. Is there another approach to handle my problem? It should, otherwise why writing about Domain Mode in Keycloak Release documentation. Unfortunately, I have not found (yet ) &nbsp;detailed &nbsp;info on how to configure a Keycloak Domain Cluster and how to do test simulations with it. I would appreciate any help on this issue.</div><div>Thanks,</div><div>Ioan &nbsp;</div><div>&nbsp;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div></div></div><br>_______________________________________________<br>
keycloak-user mailing list<br>
<a href="mailto:keycloak-user@lists.jboss.org" target="_blank">keycloak-user@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/keycloak-user" rel="noreferrer" target="_blank">https://lists.jboss.org/mailman/listinfo/keycloak-user</a><br></blockquote></div><br></div>
</div><br></div></div></div><br>_______________________________________________<br>keycloak-user mailing list<br>keycloak-user@lists.jboss.org<br>https://lists.jboss.org/mailman/listinfo/keycloak-user</div><br></div></body></html>