Improve the REMOTE_USER (for example mod_auth_kerb) support

This series of patches addresses http://projects.theforeman.org/issues/3312, making it possible to set up a protected "logon" location in Apache via
```
<Location /users/extlogin>
...
</Location>
```

and configure mod_auth_* authentication modules for that location. It was tested with mod_auth_kerb.

The possibilities and issues with the existing REMOTE_USER support are listed at http://projects.theforeman.org/projects/foreman/wiki/Foreman_and_mod_auth_kerb, together with explanations introduced by this pull request.

This is a refactoring of https://github.com/theforeman/foreman/pull/958, addressing all comments in that pull request.