Documentation ¶
Index ¶
- Constants
- func InitPolicy(enforcer casbin.IEnforcer, securityConfig *SecurityConfig, rules [][]string) error
- func MustNewEnforcer(securityConfig *SecurityConfig, db *gorm.DB) casbin.IEnforcer
- func NewEnforcer(securityConfig *SecurityConfig, db *gorm.DB) (casbin.IEnforcer, error)
- type AuthTicket
- type JWTConfig
- type JWTOper
- type JWTPayload
- type ReplayChecker
- type SecurityConfig
- type SignKeyStore
Constants ¶
View Source
const ( // RedisKeyRequestID - nfgo:reqid:{requestID} RedisKeyRequestID ntypes.Key = "nfgo:reqid:%s" )
View Source
const ( // RedisKeySignKey - nfgo:signkey:{appType}:{subject} RedisKeySignKey ntypes.Key = "nfgo:signkey:%s:%s" )
Variables ¶
This section is empty.
Functions ¶
func InitPolicy ¶
func InitPolicy(enforcer casbin.IEnforcer, securityConfig *SecurityConfig, rules [][]string) error
InitPolicy -
func MustNewEnforcer ¶
func MustNewEnforcer(securityConfig *SecurityConfig, db *gorm.DB) casbin.IEnforcer
MustNewEnforcer -
func NewEnforcer ¶
func NewEnforcer(securityConfig *SecurityConfig, db *gorm.DB) (casbin.IEnforcer, error)
NewEnforcer -
Types ¶
type AuthTicket ¶
type AuthTicket struct { ClientType string RequestID string Token string Subject string Timestamp string Signature string }
AuthTicket -
func (*AuthTicket) VerifySignature ¶
func (a *AuthTicket) VerifySignature(signKey string) bool
VerifySignature -
func (*AuthTicket) VerifyTimeWindow ¶
func (a *AuthTicket) VerifyTimeWindow(timeWindow time.Duration) error
VerifyTimeWindow - check IsoverTimeWindow clientTs milliseconds since January 1, 1970 UTC.
func (*AuthTicket) VerifyToken ¶
func (a *AuthTicket) VerifyToken(validateFn func(token string) (*JWTPayload, error)) error
VerifyToken -
type JWTOper ¶ added in v0.4.0
type JWTOper interface { IssueToken(subject string, expiration time.Time, set map[string]interface{}) (string, error) ParseToken(token string) (*JWTPayload, error) ValidateToken(token string) (*JWTPayload, error) }
func MustNewJWTOper ¶ added in v0.4.0
func MustNewJWTOper(config *SecurityConfig) JWTOper
func NewJWTOper ¶ added in v0.4.0
func NewJWTOper(config *SecurityConfig) (JWTOper, error)
type JWTPayload ¶ added in v0.4.0
type ReplayChecker ¶
ReplayChecker -
func NewRedisReplayChecker ¶
func NewRedisReplayChecker(redisOper ndb.RedisOper, securityConfig *SecurityConfig) ReplayChecker
NewRedisReplayChecker -
type SecurityConfig ¶
type SecurityConfig struct { JWT *JWTConfig `yaml:"jwt"` SignKeyLifeTime time.Duration `yaml:"signKeyLifeTime"` RefreshSignKeyLife bool `yaml:"refreshSignKeyLife"` TimeWindow time.Duration `yaml:"timeWindow"` Anons []string `yaml:"anons"` Model string `yaml:"model"` Policies []string `yaml:"policies"` }
SecurityConfig -
func (*SecurityConfig) SetDefaultValues ¶
func (conf *SecurityConfig) SetDefaultValues()
SetDefaultValues -
type SignKeyStore ¶
type SignKeyStore interface { Store(clientType, subject, signKey string) error Get(clientType, subject string) (string, error) }
SignKeyStore -
func NewRedisSignKeyStore ¶
func NewRedisSignKeyStore(redisOper ndb.RedisOper, securityConfig *SecurityConfig) SignKeyStore
NewRedisSignKeyStore -
Click to show internal directories.
Click to hide internal directories.