refactor basic auth