auth

package
v0.0.0-...-5be9e78 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	USER_KIND_ADMIN  = 1
	USER_KIND_COMMON = 2
)
View Source
const (
	REALM = "mdoc"
)

Variables

View Source
var (
	ErrNeedLogin = errors.New("Need login")
	ErrNeedPwd   = errors.New("Passwd failed")
	ErrReject    = errors.New("Too many login failures")
)

Functions

func AddUser

func AddUser(uInfo *UserInfo) error

func AuthReq

func AuthReq(server, uri, adminUser, adminPwd string, params url.Values) error

func DelAuthCache

func DelAuthCache(username string)

func GetAuthCache

func GetAuthCache(username string) (string, bool)

func GetDB

func GetDB() *database.DB

func HasDB

func HasDB() bool

func HashPasswd

func HashPasswd(user, realm, passwd string) string

func InitDB

func InitDB(dbFile string)

func ResetPwd

func ResetPwd(username, passwd string) error

func UpdateAuthCache

func UpdateAuthCache(username, token string)

Types

type DigestAuth

type DigestAuth struct {
	*httpauth.DigestAuth
	// contains filtered or unexported fields
}

func NewDigestAuth

func NewDigestAuth(realm string, plainTextSecret bool, secret httpauth.SecretProvider) *DigestAuth

About SecretProvider

plain text mode provider need return plain text, example: "hello".

hash mode provider need return H(user + ":" + realm + ":" + passwd)

func (*DigestAuth) CheckAuth

func (da *DigestAuth) CheckAuth(req *http.Request) (string, error)

rebuild httpauth.DigestAuth.CheckAuth

type IgnoreAuth

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

func NewIgnoreAuth

func NewIgnoreAuth(prefix []Prefix) *IgnoreAuth

func ParseIgnoreAuth

func ParseIgnoreAuth(data []byte) *IgnoreAuth

func (*IgnoreAuth) Match

func (n *IgnoreAuth) Match(path string) bool

type Prefix

type Prefix struct {
	Path   string
	Regexp bool
}

type UserInfo

type UserInfo struct {
	ID       string `db:"id"`
	Passwd   string `db:"passwd"`
	NickName string `db:"nick_name"`
	Kind     int    `db:"kind"`
}

func GetUser

func GetUser(username string) (*UserInfo, error)

Jump to

Keyboard shortcuts

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