Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EnableCookieStateKeeper ¶
func EnableCookieStateKeeper()
EnableCookieStateKeeper enable jwt cookie to keep state
func ProvideAuthenticator ¶
func ProvideAuthenticator(name string, f interface{})
ProvideAuthenticator provide auther
func ProvideStateKeeper ¶
func ProvideStateKeeper(newFn interface{})
ProvideStateKeeper provide custom StateKeeper implementation
Types ¶
type Authenticator ¶
type Authenticator interface {
// EnableGlobal to enable gin middleware globally to reject all requests that are not authencated.
EnableGlobal(option *Option)
// SkipPathGlobal to ignore then given request path for checking their authencation globally.
SkipPathGlobal(path string)
// EnableGroup enable middleware on the given router group to reject all requests that are not authencated.
EnableGroup(r *gin.RouterGroup, option *Option)
// SkipPath to ignore the given request for checking their authencation on the given router group.
SkipPath(r *gin.RouterGroup, path string)
// Username returns current username.
Username(c *gin.Context) (string, bool)
}
Authenticator defines how to authenticate users.
type StateKeeper ¶
type StateKeeper interface {
fmt.Stringer
// Set set state.
Set(c *gin.Context, key string, value interface{})
// Get item from state.
Get(key string) (interface{}, bool)
// GetString get string item from state
GetString(key string) (string, bool)
// GetInt get int itm from state
GetInt(key string) (int, bool)
// GetFloat64 get float64 item from state
GetFloat64(key string) (float64, bool)
// Restore restore state and sync all state to gin.Context
Restore(c *gin.Context) error
// Save state, such as cookie or something else.
Save(c *gin.Context) error
// Clear clear state
Clear(c *gin.Context) error
// CookieName returns cookie name
CookieName() string
// EncodeCookieValue encode cookie value
EncodeCookieValue() (string, error)
}
StateKeeper declare how to keep the authentication state.
Click to show internal directories.
Click to hide internal directories.