tokens

package
v0.0.0-...-732ec5d Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const HeaderName = "RPC-Authorization"

HeaderName is the HTTP header name for the rpcproxy authorization token

Variables

View Source
var ErrInvalidCountryCode = errors.New("invalid country code")

ErrInvalidCountryCode is returned when the country code is invalid

View Source
var ErrTokenCorrupted = errors.New("token is corrupt")

ErrTokenCorrupted is returned when a token has been tampered with

View Source
var ErrTokenExpired = errors.New("token has expired")

ErrTokenExpired is returned when a token has expired

Functions

func GenerateToken

func GenerateToken(secretKey []byte, validFor time.Duration, remoteAddress, userAgent, countryCode string) (string, time.Time, error)

GenerateToken generates an authorization token

Types

type Parser

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

Parser parses authorization tokens

func NewParser

func NewParser(secretKey []byte) *Parser

NewParser creates a new Parser

func (*Parser) Parse

func (p *Parser) Parse(stringToken, expectedRemoteAddress, expectedUserAgent string) (string, error)

Parse parses an authorization token and checks that it is within the validity period

Jump to

Keyboard shortcuts

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