Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidSignature is returned when the signature is invalid. ErrInvalidSignature = errors.New("invalid signature") // ErrInvalidFormat is returned when the format of the signed URL is // invalid. ErrInvalidFormat = errors.New("invalid format") // ErrExpired is returned when a signed URL has expired. ErrExpired = errors.New("URL has expired") // Default formatter is the query formatter. DefaultFormatter = WithQueryFormatter() // Default expiry encoding is base10 (decimal) DefaultExpiryFormatter = WithDecimalExpiry() )
Functions ¶
This section is empty.
Types ¶
type Option ¶
type Option func(*Signer)
Option permits customising the construction of a Signer
func PrefixPath ¶
PrefixPath prefixes the signed URL's path with a string. This can make it easier for a server to differentiate between signed and non-signed URLs. Note: the prefix is not part of the signature computation.
func SkipQuery ¶
func SkipQuery() Option
SkipQuery instructs Signer to skip the query string when computing the signature. This is useful, say, if you have pagination query parameters but you want to use the same signed URL regardless of their value.
func SkipScheme ¶ added in v0.0.6
func SkipScheme() Option
SkipScheme instructs Signer to skip the scheme when computing the signature. This is useful, say, if you generate signed URLs in production where you use https but you want to use these URLs in development too where you use http.
func WithBase58Expiry ¶ added in v0.0.4
func WithBase58Expiry() Option
WithBase58Expiry instructs Signer to use base58 to encode the expiry
func WithDecimalExpiry ¶ added in v0.0.4
func WithDecimalExpiry() Option
WithDecimalExpiry instructs Signer to use base10 to encode the expiry
func WithPathFormatter ¶
func WithPathFormatter() Option
WithPathFormatter instructs Signer to store the signature and expiry in the path of a signed URL.
func WithQueryFormatter ¶
func WithQueryFormatter() Option
WithQueryFormatter instructs Signer to use query parameters to store the signature and expiry in a signed URL.
type Signer ¶
type Signer struct {
// contains filtered or unexported fields
}
Signer is capable of signing and verifying signed URLs with an expiry.
func New ¶
New constructs a new signer, performing the one-off task of generating a secure hash from the key. The key must be between 0 and 64 bytes long; anything longer is truncated. Options alter the default format and behaviour of signed URLs.