auth

package
v0.0.0-...-bf9708b Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const COOKIE_TOKEN_NAME = "token"
View Source
const HeaderAuthReqId = "Authentication-Request-ID"
View Source
const HeaderAuthServerNonce = "Authentication-Server-Nonce"
View Source
const JWT_ALG = "HS256"
View Source
const JWT_TYP = "JWT"
View Source
const MAX_TOKEN_AGE = 60
View Source
const REQID_SIZE = 8
View Source
const SNONCE_SIZE = 16
View Source
const WAIT_TIME = 20 * time.Second

Variables

View Source
var AuthRequests = make(map[string][SNONCE_SIZE]byte)

Functions

func BakeCookieWithJWT

func BakeCookieWithJWT(jwt string) *http.Cookie

func BcryptString

func BcryptString(input string) string

func DecryptPassword

func DecryptPassword(r *http.Request, pass *models.Password, clientNonce *models.Nonce) (string, error)

func EncodeJWT

func EncodeJWT(payload PayloadJWT) string

func GetServerNonce

func GetServerNonce(r *http.Request) ([]byte, error)

func IssueJWT

func IssueJWT(name string) string

func ParseJWTCookie

func ParseJWTCookie(r *http.Request) (string, error)

func ServerNonceHandler

func ServerNonceHandler(w http.ResponseWriter, r *http.Request)

func ValidateJWT

func ValidateJWT(r *http.Request) error

Types

type HeaderJWT

type HeaderJWT struct {
	Alg string `json:"alg"`
	Typ string `json:"typ"`
}

type PayloadJWT

type PayloadJWT struct {
	IAT  int64  `json:"iat"`
	EXP  int64  `json:"exp"`
	Name string `json:"name"`
}

func ParseLoadFromJWT

func ParseLoadFromJWT(jwtString string) (PayloadJWT, error)

Jump to

Keyboard shortcuts

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