Documentation
¶
Index ¶
- type JWTTokenService
- type JwtServiceProvider
- func (p *JwtServiceProvider) Boot(ctx context.Context) error
- func (p *JwtServiceProvider) Conf() map[string]string
- func (p *JwtServiceProvider) Description() string
- func (p *JwtServiceProvider) Register(ctx context.Context) error
- func (p *JwtServiceProvider) SetApplication(app foundation.Application)
- type Options
- type TokenAuthorizer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type JWTTokenService ¶
type JWTTokenService struct {
// contains filtered or unexported fields
}
func NewJWTTokenService ¶
func NewJWTTokenService(opt Options) (*JWTTokenService, error)
func (*JWTTokenService) Issue ¶
func (s *JWTTokenService) Issue(ctx context.Context, claims contractAuth.Claims, ttlSeconds int) (string, error)
func (*JWTTokenService) Options ¶
func (s *JWTTokenService) Options() Options
func (*JWTTokenService) Parse ¶
func (s *JWTTokenService) Parse(ctx context.Context, tokenString string) (contractAuth.Claims, error)
type JwtServiceProvider ¶
type JwtServiceProvider struct {
// contains filtered or unexported fields
}
func (*JwtServiceProvider) Boot ¶
func (p *JwtServiceProvider) Boot(ctx context.Context) error
func (*JwtServiceProvider) Conf ¶
func (p *JwtServiceProvider) Conf() map[string]string
func (*JwtServiceProvider) Description ¶
func (p *JwtServiceProvider) Description() string
func (*JwtServiceProvider) Register ¶
func (p *JwtServiceProvider) Register(ctx context.Context) error
func (*JwtServiceProvider) SetApplication ¶
func (p *JwtServiceProvider) SetApplication(app foundation.Application)
type Options ¶
type TokenAuthorizer ¶
type TokenAuthorizer struct {
// contains filtered or unexported fields
}
TokenAuthorizer 基于 TokenService 做认证;可选 Casbin 做授权。
func NewTokenAuthorizer ¶
func NewTokenAuthorizer(tokens contractAuth.TokenService, enforcer *casbin.SyncedEnforcer) *TokenAuthorizer
func (*TokenAuthorizer) Authenticate ¶
func (a *TokenAuthorizer) Authenticate(ctx context.Context, rawToken string) (contractAuth.Claims, error)
func (*TokenAuthorizer) Authorize ¶
func (a *TokenAuthorizer) Authorize(ctx context.Context, claims contractAuth.Claims, permission string) error
func (*TokenAuthorizer) IsSuperAdmin ¶
func (a *TokenAuthorizer) IsSuperAdmin(claims contractAuth.Claims) bool
Source Files
¶
- jwt_service_provider.go
- jwt_token_service.go
- options.go
- token_authorizer.go
Click to show internal directories.
Click to hide internal directories.