Refactor auth_cfg applying to a common function