title: How do i pass the authenticated user from apache kerberos to tomcat GET reques
body: <p>I'm using Kerberos Mod with apache to authenticate windows user on our intranet sites which are hosted on Ubuntu servers. The backend that gets the data is tomcat. the site in question make a GET request to <a href="https://siteName/user/logMeIn" rel="nofollow noreferrer">https://siteName/user/logMeIn</a> . When I try to get the username from the header it's not there.</p>
  
  <p>I've tried adding 
      RequestHeader set X-Remote-User expr=%{REMOTE_USER}
      RequestHeader set X-REMOTE-USER %{REMOTE_USER}s
  to the apache virtual host file on separate occasions</p>
  
  <p>apache Virtual host file</p>
  
  <pre><code>&lt;IfModule mod_ssl.c&gt;
          &lt;VirtualHost _default_:443&gt;
                 ServerAdmin [serverAdmin]
                 ServerName [SiteName]
                 ServerAlias [SiteName]
  
                 DocumentRoot [Directory]
  
                 JkMount /ConferenceSchedulerService/* ConferenceSchedulerServicetomcat
  
                 ErrorLog ${APACHE_LOG_DIR}/error.log
                 CustomLog ${APACHE_LOG_DIR}/access.log combined
  
                 SSLEngine on
  
  
                 SSLCertificateFile     [CertFilePath]
                 SSLCertificateKeyFile [CertKeyFilePath]
                 &lt;FilesMatch "\.(cgi|shtml|phtml|php)$"&gt;
                                 SSLOptions +StdEnvVars
                 &lt;/FilesMatch&gt;
                 &lt;Directory /usr/lib/cgi-bin&gt;
                                 SSLOptions +StdEnvVars
                 &lt;/Directory&gt;
  
  
                 &lt;Directory "/var/www/schedulemeetingtestcom/html"&gt;
                         AuthzSendForbiddenOnFailure On
                         Options None
                         AllowOverride None
                         Order allow,deny
                         Allow from all
  
                         AuthName "SSO Failed please enter you windows    login"
                         AuthType Kerberos
                         KrbAuthRealms CORP.COMPANYNAME.COM
                         KrbServiceName HTTP/schedulemeetingtest.com
                         #KrbServiceName Any
                         Krb5KeyTab /etc/krb5.keytab
                         KrbMethodK5Passwd off
                         KrbLocalUserMapping on
                         KrbSaveCredentials on
                         SSLRequireSSL
                         Require valid-user
  
                         RequestHeader set X-Remote-User expr=%{REMOTE_USER}
                         #RequestHeader set X-REMOTE-USER %{REMOTE_USER}s
                 &lt;/Directory&gt;
  
                  BrowserMatch "MSIE [2-6]" \
          nokeepalive ssl-unclean-shutdown \
          downgrade-1.0 force-response-1.0
  
         &lt;/VirtualHost&gt;
  </code></pre>
  
  <p></p>
  
  <p>Java Spring Code</p>
  
  <pre><code>@Controller
  @RequestMapping("/user")
  public class UserController extends BaseController {
  
     @Autowired
     ApplicationUserAccessLdapService ldapSrv;
  
     @Autowired
     private HttpServletRequest request;
  
  
     @PostMapping(value="/logMeIn")
     public ResponseEntity&lt;?&gt; auth(
     ){
  
         request.getHeaderNames().toString();
         Enumeration&lt;String&gt; header = request.getHeaderNames();
         Map&lt;String, String&gt; map = new HashMap&lt;String, String&gt;();
         while (header.hasMoreElements()) {
             String key = (String) header.nextElement();
             String value = request.getHeader(key);
             map.put(key, value);
         } 
         try{
                map.put("RemoteUserName", request.getRemoteUser());
         }catch(Exception e){
             map.put("RemoteUserName", "Unknown");
         }
         try{
             map.put("RemoteAddress", request.getRemoteAddr());
         }catch(Exception e){
             map.put("RemoteAddress", "Unknown");
         }
         try{
             map.put("AuthType", request.getAuthType());
         }catch(Exception e){
             map.put("AuthType", "Unknown");
         }
         try{
             map.put("SeverletPath", request.getServletPath());
         }catch(Exception e){
             map.put("SeverletPath", "Unknown");
         }
         try{
             map.put("PrincipalName", request.getUserPrincipal().getName());
         }catch(Exception e){
             map.put("PrincipalName", "Unknown");
         }
         return new ResponseEntity(map,HttpStatus.OK);
     }
   }
  </code></pre>
  
  <p>I'm not getting the username at all and maybe it's because the kerberos mod doesn't pass the username after the initial authentication. But I still need it after
  Below is the response from the get request</p>
  
  <p>Accept-Encoding: "gzip, deflate, br"</p>
  
  <p>Accept-Language: "en-US,en;q=0.9"</p>
  
  <p>AuthType: null</p>
  
  <p>Origin: "<a href="https://schedulemeetingtest.riverstonegroup.com" rel="nofollow noreferrer">https://schedulemeetingtest.riverstonegroup.com</a>"</p>
  
  <p>PrincipalName: "Unknown"</p>
  
  <p>RemoteAddress: "192.168.93.140"</p>
  
  <p>RemoteUserName: null</p>
  
  <p>Sec-Fetch-Mode: "cors"</p>
  
  <p>Sec-Fetch-Site: "same-origin"</p>
  
  <p>SeverletPath: "/user/logMeIn"</p>
  
  <p>accept: "application/json, text/plain, <em>/</em>"</p>
  
  <p>connection: "keep-alive"</p>
  
  <p>content-length: "0"</p>
  
  <p>content-type: "application/x-www-form-urlencoded"</p>
  
  <p>host: "schedulemeetingtest.riverstonegroup.com"</p>
  
  <p>referer: "<a href="https://schedulemeetingtest.riverstonegroup.com/" rel="nofollow noreferrer">https://schedulemeetingtest.riverstonegroup.com/</a>"</p>
  
  <p>user-agent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 
  (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36"</p>
  
  <p>What i would like to see is the RemoteUserName show the user not null</p>