Documentation ¶
Index ¶
- Variables
- func AuthContentFromContext(ctx context.Context) (content []byte, err error)
- func AuthFromContext(ctx context.Context) interface{}
- func SetBuiltInTokenFn(f func(context.Context, string) (interface{}, error, bool))
- func SetWithPermissionFn(f func(interface{}) bool)
- func WithConfContext(jwt *Jwt) func(context.Context) context.Context
- type Auth
- type Claims
- type Error
- type Jwt
- func (c *Jwt) ExpiresAt() *jwt.NumericDate
- func (c *Jwt) GenerateTokenByPayload(payload interface{}) (string, error)
- func (c *Jwt) GenerateTokenWithoutExpByPayload(payload interface{}) (string, error)
- func (c *Jwt) Init()
- func (c *Jwt) ParseToken(v string) (*Claims, error)
- func (c *Jwt) SetDefault()
- type SigningMethod
- func (v SigningMethod) ConstValues() []enum.IntStringerEnum
- func (v SigningMethod) Int() int
- func (v SigningMethod) Label() string
- func (v SigningMethod) MarshalText() ([]byte, error)
- func (v *SigningMethod) Scan(src interface{}) error
- func (v SigningMethod) String() string
- func (v SigningMethod) TypeName() string
- func (v *SigningMethod) UnmarshalText(data []byte) error
- func (v SigningMethod) Value() (driver.Value, error)
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrEmptyJwtContext = errors.New("empty jwt context") ErrNoPermission = errors.New("no permission") )
View Source
var InvalidSigningMethod = errors.New("invalid SigningMethod type")
View Source
var SigningMethods = map[SigningMethod]jwt.SigningMethod{ SIGNING_METHOD_UNKNOWN: jwt.SigningMethodNone, SIGNING_METHOD__ECDSA256: jwt.SigningMethodES256, SIGNING_METHOD__ECDSA384: jwt.SigningMethodES384, SIGNING_METHOD__ECDSA512: jwt.SigningMethodES512, SIGNING_METHOD__HMAC256: jwt.SigningMethodHS256, SIGNING_METHOD__HMAC384: jwt.SigningMethodHS384, SIGNING_METHOD__HMAC512: jwt.SigningMethodHS512, SIGNING_METHOD__RSA256: jwt.SigningMethodRS256, SIGNING_METHOD__RSA384: jwt.SigningMethodRS384, SIGNING_METHOD__RSA512: jwt.SigningMethodRS512, SIGNING_METHOD__RSAPSS256: jwt.SigningMethodPS256, SIGNING_METHOD__RSAPSS384: jwt.SigningMethodPS384, SIGNING_METHOD__RSAPSS512: jwt.SigningMethodPS512, }
View Source
var WithPermissionFn func(interface{}) bool
Functions ¶
func AuthContentFromContext ¶ added in v1.4.1
func AuthFromContext ¶
func SetBuiltInTokenFn ¶
func SetWithPermissionFn ¶
func SetWithPermissionFn(f func(interface{}) bool)
Types ¶
type Auth ¶
type Auth struct { AuthInQuery string `name:"authorization,omitempty" in:"query" validate:"@string[1,]"` AuthInHeader string `name:"Authorization,omitempty" in:"header" validate:"@string[1,]"` }
func (Auth) ContextKey ¶
func (r Auth) ContextKey() interface{}
type Error ¶
type Error int
const ( // @errTalk Invalid Token InvalidToken // @errTalk Invalid Claim InvalidClaim )
func (Error) ServiceCode ¶
func (Error) StatusCode ¶
type Jwt ¶
func MustConfFromContext ¶
func (*Jwt) GenerateTokenByPayload ¶
func (*Jwt) GenerateTokenWithoutExpByPayload ¶ added in v1.1.0
func (*Jwt) SetDefault ¶
func (c *Jwt) SetDefault()
type SigningMethod ¶
type SigningMethod uint8
const ( SIGNING_METHOD_UNKNOWN SigningMethod = iota SIGNING_METHOD__ECDSA256 SIGNING_METHOD__ECDSA384 SIGNING_METHOD__ECDSA512 SIGNING_METHOD__HMAC256 SIGNING_METHOD__HMAC384 SIGNING_METHOD__HMAC512 SIGNING_METHOD__RSA256 SIGNING_METHOD__RSA384 SIGNING_METHOD__RSA512 SIGNING_METHOD__RSAPSS256 SIGNING_METHOD__RSAPSS384 SIGNING_METHOD__RSAPSS512 )
func ParseSigningMethodFromLabel ¶
func ParseSigningMethodFromLabel(s string) (SigningMethod, error)
func ParseSigningMethodFromString ¶
func ParseSigningMethodFromString(s string) (SigningMethod, error)
func (SigningMethod) ConstValues ¶
func (v SigningMethod) ConstValues() []enum.IntStringerEnum
func (SigningMethod) Int ¶
func (v SigningMethod) Int() int
func (SigningMethod) Label ¶
func (v SigningMethod) Label() string
func (SigningMethod) MarshalText ¶
func (v SigningMethod) MarshalText() ([]byte, error)
func (*SigningMethod) Scan ¶
func (v *SigningMethod) Scan(src interface{}) error
func (SigningMethod) String ¶
func (v SigningMethod) String() string
func (SigningMethod) TypeName ¶
func (v SigningMethod) TypeName() string
func (*SigningMethod) UnmarshalText ¶
func (v *SigningMethod) UnmarshalText(data []byte) error
Click to show internal directories.
Click to hide internal directories.