Documentation
¶
Index ¶
- Constants
- func AuthMW() gin.HandlerFunc
- func Init(s *redis.Client, data ...Data) gin.HandlerFunc
- func IsRole(c *gin.Context, role string) bool
- func New() string
- func RoleMW(roles ...string) gin.HandlerFunc
- type Data
- type DataMap
- type DataStringSlice
- type DefaultData
- func (d *DefaultData) Account() string
- func (d *DefaultData) Delete(key string) Data
- func (d *DefaultData) Get(key string) any
- func (d *DefaultData) ID() string
- func (d *DefaultData) Items() DataMap
- func (d *DefaultData) New() string
- func (d *DefaultData) Roles() []string
- func (d *DefaultData) Set(key string, val any) Data
- func (d *DefaultData) SetAccount(v string) Data
- func (d *DefaultData) SetID(v string) Data
- func (d *DefaultData) SetRoles(v []string) Data
- func (d *DefaultData) SetToken(v string) Data
- func (d *DefaultData) SetValues(k string, v any) Data
- func (d *DefaultData) Token() string
- type RedisStore
- type Session
- func (s *Session) Account() string
- func (s *Session) Clear()
- func (s *Session) Data() Data
- func (s *Session) Delete(key string)
- func (s *Session) Get(key string) any
- func (s *Session) HasRole(role string) bool
- func (s *Session) ID() string
- func (s *Session) MarshalJSON() ([]byte, error)
- func (s *Session) Roles() []string
- func (s *Session) Save(lifetime ...time.Duration) error
- func (s *Session) Set(key string, val any)
- func (s *Session) SetAccount(val string)
- func (s *Session) SetID(val string)
- func (s *Session) SetRoles(roles []string)
- func (s *Session) SetValues(key string, val any)
- func (s *Session) Token() string
- func (s *Session) UnmarshalJSON(data []byte) error
Constants ¶
View Source
const ( DefaultKey = "github.com/virzz/ginx/auth" TokenKey = "github.com/virzz/ginx/auth/token" )
Variables ¶
This section is empty.
Functions ¶
func AuthMW ¶
func AuthMW() gin.HandlerFunc
func RoleMW ¶
func RoleMW(roles ...string) gin.HandlerFunc
Types ¶
type DataMap ¶
func (DataMap) MarshalBinary ¶
func (*DataMap) UnmarshalBinary ¶
func (*DataMap) UnmarshalJSON ¶
func (*DataMap) UnmarshalText ¶
type DataStringSlice ¶
type DataStringSlice []string
func (DataStringSlice) MarshalBinary ¶
func (d DataStringSlice) MarshalBinary() ([]byte, error)
func (*DataStringSlice) UnmarshalBinary ¶
func (d *DataStringSlice) UnmarshalBinary(buf []byte) error
func (*DataStringSlice) UnmarshalJSON ¶
func (d *DataStringSlice) UnmarshalJSON(buf []byte) error
func (*DataStringSlice) UnmarshalText ¶
func (d *DataStringSlice) UnmarshalText(buf []byte) error
type DefaultData ¶
type DefaultData struct {
Token_ string `json:"token" redis:"token"`
ID_ string `json:"id" redis:"id"`
Account_ string `json:"account" redis:"account"`
Roles_ DataStringSlice `json:"roles" redis:"roles"`
Items_ DataMap `json:"items" redis:"items"`
}
func (*DefaultData) Account ¶
func (d *DefaultData) Account() string
func (*DefaultData) Delete ¶
func (d *DefaultData) Delete(key string) Data
func (*DefaultData) Get ¶
func (d *DefaultData) Get(key string) any
func (*DefaultData) ID ¶
func (d *DefaultData) ID() string
func (*DefaultData) Items ¶
func (d *DefaultData) Items() DataMap
func (*DefaultData) New ¶
func (d *DefaultData) New() string
func (*DefaultData) Roles ¶
func (d *DefaultData) Roles() []string
func (*DefaultData) SetAccount ¶
func (d *DefaultData) SetAccount(v string) Data
func (*DefaultData) SetID ¶
func (d *DefaultData) SetID(v string) Data
func (*DefaultData) SetRoles ¶
func (d *DefaultData) SetRoles(v []string) Data
func (*DefaultData) SetToken ¶
func (d *DefaultData) SetToken(v string) Data
func (*DefaultData) Token ¶
func (d *DefaultData) Token() string
type RedisStore ¶
type RedisStore struct {
// contains filtered or unexported fields
}
func NewRedisStore ¶
func NewRedisStore(client redis.UniversalClient, maxAge ...int) (*RedisStore, error)
type Session ¶
func NewSession ¶
func (*Session) MarshalJSON ¶
func (*Session) SetAccount ¶
func (*Session) UnmarshalJSON ¶
Click to show internal directories.
Click to hide internal directories.