Documentation ¶
Index ¶
- Constants
- func RegisterValidFunc(authType string, validFunc ValidFunc)
- type Auth
- type AuthExtend
- func (c AuthExtend) GetAudience() (jwt.ClaimStrings, error)
- func (c AuthExtend) GetExpirationTime() (*jwt.NumericDate, error)
- func (c AuthExtend) GetIssuedAt() (*jwt.NumericDate, error)
- func (c AuthExtend) GetIssuer() (string, error)
- func (c AuthExtend) GetNotBefore() (*jwt.NumericDate, error)
- func (c AuthExtend) GetSubject() (string, error)
- type Token
- type ValidFunc
Constants ¶
View Source
const ( TypeJWT = "jwt" DefaultDuration = int64(2 * 3600) )
Variables ¶
This section is empty.
Functions ¶
func RegisterValidFunc ¶
RegisterValidFunc 注册校验函数
Types ¶
type Auth ¶
type Auth struct { Foo string `json:"foo"` UID int64 `json:"uid"` RoleID int64 `json:"role_id"` IsAdmin int64 `json:"is_admin"` AuthExtend }
type AuthExtend ¶
type AuthExtend jwt.RegisteredClaims
func (AuthExtend) GetAudience ¶
func (c AuthExtend) GetAudience() (jwt.ClaimStrings, error)
GetAudience implements the Claims interface.
func (AuthExtend) GetExpirationTime ¶
func (c AuthExtend) GetExpirationTime() (*jwt.NumericDate, error)
GetExpirationTime implements the Claims interface.
func (AuthExtend) GetIssuedAt ¶
func (c AuthExtend) GetIssuedAt() (*jwt.NumericDate, error)
GetIssuedAt implements the Claims interface.
func (AuthExtend) GetIssuer ¶
func (c AuthExtend) GetIssuer() (string, error)
GetIssuer implements the Claims interface.
func (AuthExtend) GetNotBefore ¶
func (c AuthExtend) GetNotBefore() (*jwt.NumericDate, error)
GetNotBefore implements the Claims interface.
func (AuthExtend) GetSubject ¶
func (c AuthExtend) GetSubject() (string, error)
GetSubject implements the Claims interface.
type Token ¶
type Token string
func (Token) SetCookie ¶
func (t Token) SetCookie(w http.ResponseWriter, cookieName string)
SetCookie 将jwt Token保存到cookie中
func (Token) SetHeader ¶
func (t Token) SetHeader(w http.ResponseWriter)
SetHeader 将jwt Token保存到请求返回的X-Auth头部
Click to show internal directories.
Click to hide internal directories.