sessionguard

package
v5.3.3-pre1 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: AGPL-3.0 Imports: 14 Imported by: 1

Documentation

Index

Constants

View Source
const InvalidIPAddress = `invalid ip address`

Variables

This section is empty.

Functions

func EnvKey added in v5.2.5

func EnvKey(ctx echo.Context) string

func GetLastLoginInfo

func GetLastLoginInfo(ctx echo.Context, ownerType string, ownerId uint64, sessionId string) (*dbschema.NgingLoginLog, error)

func Unpack added in v5.2.5

func Unpack(ctx echo.Context, encrypted string) (password string, err error)

func UnsetSession

func UnsetSession(ctx echo.Context, ownerType string)

func Validate

func Validate(ctx echo.Context, lastIP string, ownerType string, ownerId uint64) bool

Validate 验证 session 环境是否安全,避免 cookie 和 session id 被窃取 在非匿名模式下 UserAgent 和 IP 归属地与登录时的一致

func VerifyEnvKey added in v5.2.5

func VerifyEnvKey(ctx echo.Context, envKey string, dontCheckTime ...bool) error

Types

type Environment

type Environment struct {
	UserAgent string
	Location  ip2regionparser.IpInfo
}

func GetEnvFromSession

func GetEnvFromSession(ctx echo.Context, ownerType string) *Environment

func (*Environment) SetSession

func (e *Environment) SetSession(ctx echo.Context, ownerType string)

type PE added in v5.2.5

type PE struct {
	Password  string `json:"p"`
	EnvKey    string `json:"e"`
	Timestamp int64  `json:"t"`
}

func (*PE) Verify added in v5.2.5

func (p *PE) Verify(ctx echo.Context) error

Jump to

Keyboard shortcuts

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