[AuthN_KS] Cleaned up some old KS code

* DRYing up headers
* Full integration of the patch from @spinto
* Formatting changes