urlsigner

package
v0.9.3 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2023 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Algorithm

func Algorithm(alg func() hash.Hash) func(*SignerProvider)

Algorithm allows overriding of the internal hashing algorithm

func ExpirationField

func ExpirationField(name string) func(*SignerProvider)

ExpirationField allows overriding of the internal field name for expiration

func Sign

func Sign(algorithm func() hash.Hash, key, payload string) string

Sign will create a new signature based on a key and a string payload It is required to choose a hash algorithm

func SignatureField

func SignatureField(name string) func(*SignerProvider)

SignatureField allows overriding of the internal field name for signature

func Verify

func Verify(a, b string) bool

Verify will tell if two string signatures are equal

Types

type SignerProvider

type SignerProvider struct {
	// contains filtered or unexported fields
}

SignerProvider is used to sign and verify urls.

func New

func New(secretKey string, opts ...func(*SignerProvider)) *SignerProvider

New will create a new SignerProvider.

urlsigner.New("secret-key")

func (*SignerProvider) Sign

func (p *SignerProvider) Sign(u url.URL) url.URL

Sign will sign an URL object returning it updated to include the signature

func (*SignerProvider) SignTemporary

func (p *SignerProvider) SignTemporary(u url.URL, expireAt time.Time) url.URL

SignTemporary will sign an URL object for a limited period of time retuning it updated with two new query strings: signature, expiration

func (*SignerProvider) SignTemporaryURL

func (p *SignerProvider) SignTemporaryURL(rawURL string, expireAt time.Time) string

SignTemporaryURL acts like SignTemporary method but accepts the url as string instead of url.URL

func (*SignerProvider) SignURL

func (p *SignerProvider) SignURL(rawURL string) string

SignURL acts like Sign method but accepts the url as string instead of url.URL

func (*SignerProvider) Verify

func (p *SignerProvider) Verify(u url.URL) bool

Verify will check an URL object against its signature This signature should be provided by the url itself in a query string

func (*SignerProvider) VerifyTemporary

func (p *SignerProvider) VerifyTemporary(u url.URL) bool

VerifyTemporary will check an URL object against its signature and check if it's expired This signature should be provided by the url itself in a query string

func (*SignerProvider) VerifyTemporaryURL

func (p *SignerProvider) VerifyTemporaryURL(rawURL string) bool

VerifyTemporaryURL acts like VerifyTemporary method but accepts the url as string instead of url.URL

func (*SignerProvider) VerifyURL

func (p *SignerProvider) VerifyURL(rawURL string) bool

VerifyURL acts like Verify method but accepts the url as string instead of url.URL

Jump to

Keyboard shortcuts

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