Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultValidator ¶
DefaultValidator is the default request payment validator
func GenerateHMACToken ¶
GenerateHMACToken generates an HMAC token for a given url with the provided secret
func RandString ¶
RandString is a random string implementation taken from https://stackoverflow.com/questions/22892120/how-to-generate-a-random-string-of-a-fixed-length-in-go It implements an easy way to get an ephemeral HMAC secret if one is not configured.
func ValidateHMACToken ¶
ValidateHMACToken validates that an HMAC token matches for a given URL
Types ¶
type PaymentEnforcer ¶
type PaymentEnforcer struct { // Location to where we should redirect payments, and has the PaymentHandler // installed PaymentURL string // Validator is a func that validates that a request has a valid proof of // payment Validator ValidatorFunc // Secret is the HMAC secret used for generating and validating tokens // NOTE: This may be swapped out at a later date. Secret string }
PaymentEnforcer ensures that the request has been paid for properly by checking for a payment authorization. If there is no payment authorization header, then we send a BIP70 payment request
func New ¶
func New(PaymentURL string, secret string, Validator ValidatorFunc) *PaymentEnforcer
New returns a new payment enforcer that can be used for easy BIP70 integration for the keyserver.
func (*PaymentEnforcer) Middleware ¶
func (e *PaymentEnforcer) Middleware(prevHandler http.Handler) http.Handler
Middleware is a middleware function that ensures a payment has been made before allowing this endpoint to be accessed.
func (*PaymentEnforcer) PaymentHandler ¶
func (e *PaymentEnforcer) PaymentHandler(w http.ResponseWriter, r *http.Request)
PaymentHandler is an http handler that implements a check for payment, along with a redirect to the original location with the key