Refactoring of OneLogin into more general SAML authn code.

To make the SAML support more flexible and able to work with other SSO providers.
Plus a few small bug fixes.
This should include the unit test change unless I borked the pull request.