Documentation
¶
Index ¶
- Constants
- func AuthMW() gin.HandlerFunc
- func HasRole(c *gin.Context, role string) bool
- func HasRoles(c *gin.Context, roles ...string) bool
- func Init(store *redis.Client, data ...Data) gin.HandlerFunc
- 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) Clear() Data
- func (d *DefaultData) Delete(key string) Data
- func (d *DefaultData) Get(key string) any
- func (d *DefaultData) ID() uint64
- 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 uint64) Data
- func (d *DefaultData) SetRoles(v []string) Data
- func (d *DefaultData) SetState(v uint16) Data
- func (d *DefaultData) SetToken(v string) Data
- func (d *DefaultData) SetValues(k string, v any) Data
- func (d *DefaultData) State() uint16
- 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() uint64
- 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 uint64)
- func (s *Session) SetRoles(roles []string)
- func (s *Session) SetState(val uint16)
- func (s *Session) SetValues(key string, val any)
- func (s *Session) State() uint16
- func (s *Session) Token() string
- func (s *Session) UnmarshalJSON(data []byte) error
Constants ¶
View Source
const ( DefaultKey = "github.com/virzz/mulan/auth" TokenKey = "github.com/virzz/mulan/auth/token" )
Variables ¶
This section is empty.
Functions ¶
func AuthMW ¶
func AuthMW() gin.HandlerFunc
func RoleMW ¶
func RoleMW(roles ...string) gin.HandlerFunc
Types ¶
type Data ¶
type Data interface {
Token() string
ID() uint64
Account() string
State() uint16
Roles() []string
Items() DataMap
Get(string) any
New() string
Set(string, any) Data
SetToken(string) Data
SetID(uint64) Data
SetAccount(string) Data
SetState(uint16) Data
SetValues(string, any) Data
SetRoles([]string) Data
Delete(string) Data
Clear() Data
}
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_ uint64 `json:"id" redis:"id"`
Account_ string `json:"account" redis:"account"`
State_ uint16 `json:"state" redis:"state"`
Roles_ DataStringSlice `json:"roles" redis:"roles"`
Items_ DataMap `json:"items" redis:"items"`
}
func (*DefaultData) Account ¶
func (d *DefaultData) Account() string
func (*DefaultData) Clear ¶
func (d *DefaultData) Clear() Data
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() uint64
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 uint64) Data
func (*DefaultData) SetRoles ¶
func (d *DefaultData) SetRoles(v []string) Data
func (*DefaultData) SetState ¶
func (d *DefaultData) SetState(v uint16) Data
func (*DefaultData) SetToken ¶
func (d *DefaultData) SetToken(v string) Data
func (*DefaultData) State ¶
func (d *DefaultData) State() uint16
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.