Refactor remote saml authentication