auth

package
v0.0.0-...-75d2a66 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2015 License: Apache-2.0 Imports: 8 Imported by: 1

Documentation

Index

Constants

View Source
const (
	RMDefaultKey = "springCatRememberMe"
)

Variables

This section is empty.

Functions

func DefaultIsAuthenticated

func DefaultIsAuthenticated(c *gin.Context)

func DefaultLoginFailed

func DefaultLoginFailed(c *gin.Context)

func DefaultLoginSuccess

func DefaultLoginSuccess(c *gin.Context)

func DefaultLogout

func DefaultLogout(c *gin.Context)

func DefaultUnAuthenticate

func DefaultUnAuthenticate(c *gin.Context)

func GetUniqueId

func GetUniqueId(c *gin.Context) interface{}

func GetUser

func GetUser(c *gin.Context) interface{}

func IsAuthenticated

func IsAuthenticated(c *gin.Context) bool

func IsLogin

func IsLogin(c *gin.Context) bool

func Logout

func Logout(c *gin.Context) bool

func NewCookieSession

func NewCookieSession(engine *gin.Engine, conf AuthConf)

func NewDefaultCookieSession

func NewDefaultCookieSession(engine *gin.Engine, user User, MaxAge int, Secret string)

func NewDefaultRedisSession

func NewDefaultRedisSession(engine *gin.Engine, user User, MaxAge int, Secret string, redisServerAddress string, redisServerPassword string)

func NewRedisSession

func NewRedisSession(engine *gin.Engine, conf AuthConf)

func NewRememberMe

func NewRememberMe(engine *gin.Engine, cookieKey string, maxAge int, secret string)

func RequireUser

func RequireUser() gin.HandlerFunc

Types

type AuthConf

type AuthConf struct {
	Login           AuthHandle
	Logout          AuthHandle
	LoginSuccess    AuthHandle
	LoginFailed     AuthHandle
	UnAuthenticated AuthHandle
	IsAuthenticated AuthHandle
	Session         AuthSession
	Redis           AuthRedis
	LoginUser       User
}

type AuthHandle

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

type AuthRedis

type AuthRedis struct {
	Size     int
	Network  string
	Address  string
	Password string
}

type AuthSession

type AuthSession struct {
	CookieKey  string
	SessionKey string
	Secret     string
	MaxAge     int
}

type LoginError

type LoginError int
const (
	ERROR_NO_USER LoginError = (iota + 1)
	ERROR_PASSWORD_WRONG
	ERROR_NO_USER_OR_NO_PASSWORD_WRONG
	ERROR_ALREADY_LOGIN
	ERROR_ALREADY_LOGOUT
)

type RememberMeConf

type RememberMeConf struct {
	CookieKey string
	MaxAge    int
	Secret    string
}

type User

type User interface {
	UniqueId() interface{}

	Login(c *gin.Context) (u User, isRememberMe bool, err LoginError)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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