Documentation ¶
Index ¶
- func Algorithm(alg func() hash.Hash) func(*SignerProvider)
- func ExpirationField(name string) func(*SignerProvider)
- func Sign(algorithm func() hash.Hash, key, payload string) string
- func SignatureField(name string) func(*SignerProvider)
- func Verify(a, b string) bool
- type SignerProvider
- func (p *SignerProvider) Sign(u url.URL) url.URL
- func (p *SignerProvider) SignTemporary(u url.URL, expireAt time.Time) url.URL
- func (p *SignerProvider) SignTemporaryURL(rawURL string, expireAt time.Time) string
- func (p *SignerProvider) SignURL(rawURL string) string
- func (p *SignerProvider) Verify(u url.URL) bool
- func (p *SignerProvider) VerifyTemporary(u url.URL) bool
- func (p *SignerProvider) VerifyTemporaryURL(rawURL string) bool
- func (p *SignerProvider) VerifyURL(rawURL string) bool
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 ¶
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
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 ¶
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