sigparse

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 18, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package sigparse extracts identity and routing information from AWS request signatures without ever verifying them. doze-aws is a local emulator with a fixed identity, so a signature's only value is what it *names*: the access key, and — for SigV4 — the region and service the request was signed for (which the gateway uses to route a shared endpoint).

Both signature generations are understood, in both placements:

SigV4 header:    Authorization: AWS4-HMAC-SHA256 Credential=AKID/20130524/us-east-1/s3/aws4_request, SignedHeaders=..., Signature=...
SigV4 presigned: ?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKID%2F20130524%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=...&X-Amz-Expires=...
SigV2 header:    Authorization: AWS AKID:Base64Signature
SigV2 presigned: ?AWSAccessKeyId=AKID&Signature=...&Expires=1141889120

The one check that IS enforced is presigned-URL expiry (both forms): stale presigned URLs are a real, cheap-to-catch application bug.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PresignedExpiry

func PresignedExpiry(q url.Values, now time.Time) (present, expired bool)

PresignedExpiry reports whether q carries a presigned-URL expiry and, if so, whether it has passed at time now. Requests without presigned parameters return (false, false).

Types

type Scope

type Scope struct {
	AccessKeyID string
	Date        string // SigV4 credential-scope date (YYYYMMDD); empty for SigV2
	Region      string // SigV4 only
	Service     string // SigV4 signing name, e.g. "s3", "events"; empty for SigV2
	Version     int    // 2 or 4
	Presigned   bool
}

Scope identifies who a request claims to be from and, for SigV4, what it was signed for.

func Parse

func Parse(r *http.Request) (Scope, bool)

Parse extracts the signature scope from r, trying the SigV4 header, the SigV2 header, then the two presigned query forms. ok is false when the request carries no recognizable AWS signature (anonymous requests are fine — callers treat them like any other).

func ParseAuthorization

func ParseAuthorization(header string) (Scope, bool)

ParseAuthorization parses an Authorization header in either generation.

func ParsePresigned

func ParsePresigned(q url.Values) (Scope, bool)

ParsePresigned recognizes both presigned query forms.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL