jwt

package module
v0.1.15 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2024 License: MIT Imports: 14 Imported by: 2

README

JWT auth package for stdhttp

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Add

func Add(http *stdhttp.HTTP) (err error)

Add --

func CheckToken added in v0.1.9

func CheckToken(tokenRaw, tokenType, secret string) (*auth.Identity, error)

func ClientHeader added in v0.1.1

func ClientHeader(user string, secret string, lifetime time.Duration) (headerString string, err error)

Создание HTTP заголовка для метода JWT для клиента из имени пользователя и секрета

func CreateToken added in v0.1.9

func CreateToken(username string, secret string, tokenType string, now, exp time.Time) (token string, err error)

func ExtractToken added in v0.1.9

func ExtractToken(tokenRaw, secret string) (tokenType string, status bool, err error)

В теории является дубликатом CheckToken, не не знаю как лучше исправить

func GetToken

func GetToken(cfg *config.Listener, id uint64, path string, w http.ResponseWriter, r *http.Request) bool

GetToken --

func MakeTokens added in v0.1.9

func MakeTokens(username string, secret string, lifetimeAccess, lifetimeRefresh time.Duration) (access, refresh string, exp int64, err error)

func RefreshToken added in v0.1.9

func RefreshToken(cfg *config.Listener, id uint64, path string, w http.ResponseWriter, r *http.Request) bool

func VerifyToken added in v0.1.9

func VerifyToken(cfg *config.Listener, id uint64, path string, w http.ResponseWriter, r *http.Request) bool

Types

type AuthHandler

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

AuthHandler --

func (*AuthHandler) Check

func (ah *AuthHandler) Check(id uint64, prefix string, path string, w http.ResponseWriter, r *http.Request) (identity *auth.Identity, tryNext bool, err error)

Check --

func (*AuthHandler) Enabled

func (ah *AuthHandler) Enabled() bool

Enabled --

func (*AuthHandler) Handler

func (ah *AuthHandler) Handler(id uint64, prefix string, path string, w http.ResponseWriter, r *http.Request) (processed bool)

func (*AuthHandler) Init

func (ah *AuthHandler) Init(cfg *config.Listener) (err error)

Init --

func (*AuthHandler) Score

func (ah *AuthHandler) Score() int

Score --

func (*AuthHandler) WWWAuthHeader

func (ah *AuthHandler) WWWAuthHeader() (name string, withRealm bool)

WWWAuthHeader --

type JWTTokens added in v0.1.9

type JWTTokens struct {
	Access  string `json:"access"`
	Refresh string `json:"refresh"`
}

type JsonError added in v0.1.9

type JsonError struct {
	Error string `json:"error"`
}

type TokenVerify added in v0.1.9

type TokenVerify struct {
	Token string `json:"token"`
}

type TokenVerifyStatus added in v0.1.9

type TokenVerifyStatus struct {
	Type   string `json:"type"`
	Status bool   `json:"status"`
}

type UserData added in v0.1.9

type UserData struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

Jump to

Keyboard shortcuts

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