title: Spring Security Kerberos SSO for a REST API (Tomcat)
body: <p>Here is my problem:</p>
  
  <p><strong>Context</strong> : 
  -Windows Server 2012 with ActiveDirectory
  -Tomcat
  -Rest API (Spring)</p>
  
  <p>I'm currently trying to restrict REST request. I want that only specific groups of the AD could access to specific resources. I'm restricted to Kerberos authentication. </p>
  
  <p><strong>System configuration</strong></p>
  
  <ol>
  <li>Create a user in domain "Tomcat"</li>
  <li>setspn -a HTTP/apirest.domain@DOMAIN</li>
  <li>Generate a tomcat.keytab using ktpass</li>
  </ol>
  
  <p><strong>API rest configuration</strong></p>
  
  <p>I'm using the spring security sample on github that you can find here :</p>
  
  <p><a href="https://github.com/spring-projects/spring-security-kerberos/tree/master/spring-security-kerberos-samples/sec-server-win-auth" rel="nofollow noreferrer">https://github.com/spring-projects/spring-security-kerberos/tree/master/spring-security-kerberos-samples/sec-server-win-auth</a></p>
  
  <p>I know that there is an EntryPoint and this is not needed in my context (API Rest). I've chosen this sample because it seems to use the windows authentication context and use it to automatically authenticate me in the spring security context. Right after, an ldap request is send to extract all information about the user logged. In my case, I need to extract the group. </p>
  
  <p>I'm also using :</p>
  
  <p><a href="https://github.com/GyllingSW/kerberos-demo" rel="nofollow noreferrer">https://github.com/GyllingSW/kerberos-demo</a></p>
  
  <p>To extract the role of the user with the class "RoleStrippingLdapUserDetailsMapper.java" instead of the "ActiveDirectoryLdapAuthoritiesPopulator". This implementation also offers localhost authentication but the issue with the NTLM token seems to be fixed in last commit of spring security. </p>
  
  <p>I'm not really sure if this is the right way to do what I want.</p>
  
  <p>My authentication seems to fail and I only have one things going wrong in my logs..</p>
  
  <p>"Property 'userDn' not set - anonymous context will be used for read-write operations"</p>
  
  <p><strong>Questions</strong></p>
  
  <ol>
  <li>Do I have to run my tomcat service using the tomcat account ? (Seems to be, yes)</li>
  <li>Am I doing the right things with Kerberos security ?</li>
  <li>How can I get rid of the anonymous context?</li>
  <li>The anonymous context seems to be set just right after Tomcat start. I want to get a context just after that my user (For instance, user1) requests the rest API (EntryPoint or whatever)</li>
  </ol>
  
  <p>If there is something unclear let me know, I will try to reformulate!</p>
  
  <p>Thanks,</p>