auth

package
v0.0.0-...-baf4ea5 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2021 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package auth provides various authentication related utilities

Index

Constants

View Source
const (
	ErrDeserializeOutputInvalid erro.BaseError = "deserialize output is invalid because provided signature [%s] does not match computed signature [%s]"
	ErrDeserializeInputInvalid  erro.BaseError = "deserialize input [%s] is invalid because missing '.' in string"
)

Variables

This section is empty.

Functions

func AddConstProvider

func AddConstProvider(funcs template.FuncMap) template.FuncMap

func Authenticate

func Authenticate(returnTo string, errorHandler func(http.ResponseWriter, *http.Request, error)) func(http.Handler) http.Handler

func CompareHashAndPassword

func CompareHashAndPassword(passwordhash string, password string) error

func Deserialize

func Deserialize(key string, input string, outputAddr interface{}) (err error)

Deserialize will deserialize any input string back into an object that was serialized with Serialize. It requires the same key that was used to serialize the variable in order to verify the digital signature of the payload. If the digital signature doesn't match, it will return ErrDeserializeOutputInvalid

func GenerateRandomString

func GenerateRandomString() (string, error)

func Hash

func Hash(key string, input []byte) (output string)

Hash will hash input byte slice and output a string. Takes in a key to salt the hashing algorithm

THIS IS NOT SAFE FOR PASSWORD HASHING. Use HashPassword and its companion function CompareHashAndPassword instead

func HashPassword

func HashPassword(password string) (string, error)

func IsValidProvider

func IsValidProvider(provider string) bool

func Redirect

func Redirect(
	w http.ResponseWriter, r *http.Request,
	provider, returnTo string,
	errorHandler func(http.ResponseWriter, *http.Request, error),
)

func Serialize

func Serialize(key string, input interface{}) (output string, err error)

Serialize will serialize any object into a string so that it can be sent down the wire. It can be converted back later using Deserialize. It requires a key to digitally sign the output

Types

This section is empty.

Directories

Path Synopsis
Package oauth is a wrapper around x/oauth2 to provide oauth2 authetication for various providers
Package oauth is a wrapper around x/oauth2 to provide oauth2 authetication for various providers
Package openid partially implements the OpenID 2.0 specification for the Relying Party (RP) in Stateless Mode
Package openid partially implements the OpenID 2.0 specification for the Relying Party (RP) in Stateless Mode

Jump to

Keyboard shortcuts

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