Issue #8744 by tj, cleanup and using hook to alter saml settings