Refactor s3-auth