Authentication¶
Hafiz uses AWS Signature Version 4 for request authentication.
AWS Signature V4¶
All requests must include a valid signature in the Authorization header.
Header Format¶
Authorization: AWS4-HMAC-SHA256
Credential=ACCESS_KEY/DATE/REGION/s3/aws4_request,
SignedHeaders=host;x-amz-date,
Signature=CALCULATED_SIGNATURE
Required Headers¶
| Header | Description | Example |
|---|---|---|
Authorization |
Signature | AWS4-HMAC-SHA256 ... |
x-amz-date |
Timestamp | 20240101T000000Z |
x-amz-content-sha256 |
Payload hash | UNSIGNED-PAYLOAD |
Host |
Server hostname | s3.example.com |
Using AWS SDKs¶
SDKs handle signing automatically:
Presigned URLs¶
Generate time-limited URLs that don't require credentials:
# Generate presigned URL (valid 1 hour)
aws --endpoint-url http://localhost:9000 s3 presign \
s3://my-bucket/file.txt --expires-in 3600
Result:
Signature V2 (Legacy)¶
Hafiz also supports the older Signature V2 for compatibility:
Deprecated
Signature V2 is deprecated. Use Signature V4 for new applications.