auth

package
v0.0.0-...-8e7039a Latest Latest
Warning

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

Go to latest
Published: May 24, 2017 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrorBase64Decode       = "Base64DecodeFailed"
	ErrorJSONEncode         = "JSONEncodeFailed"
	ErrorJWTHeaderDecode    = "JWTHeaderDecodeFailed"
	ErrorJWTHeader          = "JWTHeaderInvalid"
	ErrorJWTClaimsDecode    = "JWTClaimsDecodeFailed"
	ErrorJWTClaims          = "JWTClaimsrInvalid"
	ErrorJWTTokenFormat     = "JWTFormatInvalid"
	ErrorJWTALGInvalid      = "JWTAlgInvalid"
	ErrorJWTSigntureInvalid = "JWTSignatureInvalid"
	ErrorJWTTokenExpired    = "JWTTokenExpired"

	AlgHS256 = "HS256"
	TypeJWT  = "JWT"
)
View Source
const (
	ErrorPasswordHash = "PasswordHashFailed"
)

Variables

This section is empty.

Functions

func CheckPassword

func CheckPassword(saved []byte, check []byte) bool

CheckPassword checks the provided password against the stored password It extracts the salt from the front of the stored value, then adds it to the password and re-computes the hash

func PasswordHash

func PasswordHash(password []byte) ([]byte, error)

PasswordHash generates a hex encoded sha1 hash of the password with crypt/rand salt The returned []byte contans the salt followed by the sha1 sum The function will only error if the install's secure random generator is not working

Types

type Claims

type Claims struct {
	Subject    string `json:"sub"`
	Expiration int    `json:"exp"`
	Issued     int    `json:"iat"`
}

Claims holds the claims to be included in the payload of the JWT

type Token

type Token struct {
	Secret   []byte
	ValidFor int
	Claims   *Claims
	// contains filtered or unexported fields
}

func NewToken

func NewToken(secret []byte, validFor int) *Token

func (*Token) Generate

func (t *Token) Generate() (string, error)

func (*Token) Parse

func (t *Token) Parse(in string) error

Parse takes a token string and validates it

Jump to

Keyboard shortcuts

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