Refactoring of sso-integration so it could be reused for oauth