signedurl

package
v2.41.0 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package signedurl provides interfaces and implementations for signing and verifying URLs.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidKey = NewSignedURLError(nil, "invalid key provided")

Functions

This section is empty.

Types

type JWTOption

type JWTOption func(o *JWTOptions)

JWTOption defines a single option function.

func WithQueryParam

func WithQueryParam(queryParam string) JWTOption

func WithSecret

func WithSecret(secret string) JWTOption

type JWTOptions

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

JWTOptions defines the available options for this package.

type JWTSignedURL

type JWTSignedURL struct {
	JWTOptions
}

JWTSignedURL implements the Signer and Verifier interfaces using JWT for signing URLs.

func NewJWTSignedURL

func NewJWTSignedURL(opts ...JWTOption) (*JWTSignedURL, error)

func (*JWTSignedURL) Sign

func (j *JWTSignedURL) Sign(unsignedURL, subject string, ttl time.Duration) (string, error)

Sign signs a URL using JWT with a specified time-to-live (ttl).

func (*JWTSignedURL) Verify

func (j *JWTSignedURL) Verify(signedURL string) (string, error)

Verify verifies a signed URL using a JWT. Returns the subject of the JWT if verification is successful.

type SignatureVerificationError

type SignatureVerificationError struct {
	SignedURLError
}

func NewSignatureVerificationError

func NewSignatureVerificationError(innerErr error) SignatureVerificationError

func (SignatureVerificationError) Is

type SignedURLError

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

func NewSignedURLError

func NewSignedURLError(innerErr error, message string) SignedURLError

NewSignedURLError creates a new SignedURLError with the provided inner error and message.

func (SignedURLError) Error

func (e SignedURLError) Error() string

Error implements the error interface for errorConst.

func (SignedURLError) Unwrap

func (e SignedURLError) Unwrap() error

type Signer

type Signer interface {
	// Sign signs a URL
	Sign(url, principal string, ttl time.Duration) (string, error)
}

type Verifier

type Verifier interface {
	// Verify verifies a signed URL
	Verify(signedURL string) (string, error)
}

Jump to

Keyboard shortcuts

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