
auth
Package auth provides S3 SigV4 (header and presigned URL) and token-based request authentication with multi-bucket credential resolution.
Index
- Constants
- Variables
- func NewChunkReader(body io.ReadCloser, mat *StreamingMaterial) io.ReadCloser
- func VerifySigV4(r *http.Request, accessKeyID, secretAccessKey string) error
- type BucketRegistry
- type StreamingMaterial
- type StreamingVariant
Constants
MaxChunkBytes is the largest single declared chunk size accepted by the reader. AWS SDKs use 64 KiB by default; the cap defends against adversarial declarations of huge chunks that would never be delivered.
Variables
ErrChunkMalformed indicates the chunk framing did not parse: missing CRLF, malformed hex, missing chunk-signature, premature EOF, etc. Maps to S3 InvalidRequest.
ErrChunkSignatureMismatch indicates a per-chunk signature did not match the value computed from the chain. Maps to S3 SignatureDoesNotMatch.
ErrChunkTooLarge indicates a declared chunk size exceeded MaxChunkBytes. Maps to S3 InvalidRequest.
ErrDecodedLengthMismatch indicates the running total of chunk bytes disagreed with x-amz-decoded-content-length. Maps to S3 IncompleteBody.
ErrTrailerMalformed indicates the trailer block did not parse: missing declared trailer header, missing trailer signature, oversized block. Maps to S3 InvalidRequest.
ErrTrailerSignatureMismatch indicates the trailer block’s signature did not match the value computed from the chain. Maps to S3 SignatureDoesNotMatch.
func NewChunkReader
NewChunkReader wraps body with a verifying decoder. The returned reader yields decoded user payload bytes only; chunk framing is consumed and validated as part of each Read. After EOF the reader has fully verified the chain, including the trailer block where applicable. mat is taken by pointer to avoid copying the embedded signing key on every request.
func VerifySigV4
VerifySigV4 checks an AWS Signature Version 4 Authorization header against the provided credentials. The caller is responsible for resolving the correct credentials via BucketRegistry. Returns nil if the signature is valid.
type BucketRegistry
BucketRegistry resolves client credentials to virtual bucket names.
func NewBucketRegistry
NewBucketRegistry builds a credential-to-bucket lookup from the config.
func (*BucketRegistry) AuthenticateAndResolveBucket
AuthenticateAndResolveBucket authenticates the request and returns the authorized bucket name plus, when the SigV4 seed signature declares a streaming payload, the StreamingMaterial that the transport layer needs to verify and decode the chunk chain. The streaming return is nil for non-streaming requests, presigned URLs, and proxy-token authentication.
func (*BucketRegistry) MaxMultipartUploads
MaxMultipartUploads returns the configured limit for active multipart uploads on the given bucket. Returns 0 if unlimited.
type StreamingMaterial
StreamingMaterial is the data the chunk reader needs to verify the chain. Built by the auth layer immediately after the seed signature verifies; carries the same signing-key derivation the seed used so the chain is bound to the request.
type StreamingVariant
StreamingVariant identifies which AWS streaming-payload mode a request declares via X-Amz-Content-Sha256.
func DetectStreamingVariant
DetectStreamingVariant maps the X-Amz-Content-Sha256 value to a streaming variant. Returns StreamingNone when the value is empty or a regular hex payload hash.
func (StreamingVariant) Label
Label returns a stable, lowercase identifier for the variant suitable as a Prometheus label value. The mapping is fixed across releases so dashboards and alert rules can match by variant without ambiguity.
Generated by gomarkdoc