Documentation
¶
Index ¶
- Variables
- type KeyFunc
- type Token
- type TokenBody
- func (*TokenBody) Descriptor() ([]byte, []int)deprecated
- func (x *TokenBody) GetAud() string
- func (x *TokenBody) GetExp() int64
- func (x *TokenBody) GetIat() int64
- func (x *TokenBody) GetIss() string
- func (x *TokenBody) GetJti() string
- func (x *TokenBody) GetNbf() int64
- func (x *TokenBody) GetPayload() *structpb.Struct
- func (x *TokenBody) GetSub() string
- func (*TokenBody) ProtoMessage()
- func (x *TokenBody) ProtoReflect() protoreflect.Message
- func (x *TokenBody) Reset()
- func (x *TokenBody) String() string
- func (c *TokenBody) Valid() error
- func (c *TokenBody) ValidWithLeeway(leeway time.Duration) error
- type TokenHeader
Constants ¶
This section is empty.
Variables ¶
var ( ErrTokenExpired = errors.New("token is expired") ErrTokenNotValidYet = errors.New("token is not yet valid (nbf)") )
Sentinel errors for token validation results.
var File_pwt_proto protoreflect.FileDescriptor
Functions ¶
This section is empty.
Types ¶
type KeyFunc ¶
KeyFunc returns the signing key used to verify a token. The function receives the parsed Token and may return an error if the key cannot be determined.
type Token ¶
type Token struct {
Header *TokenHeader
Body *TokenBody
Method jwt.SigningMethod
}
Token is a Protobuf Web Token consisting of a header, body and the signing method used to create it.
func New ¶
func New(method jwt.SigningMethod, body *TokenBody) *Token
New creates a Token with header version "1.0" using the provided signing method.
func NewVersioned ¶
func NewVersioned(method jwt.SigningMethod, body *TokenBody, version string) *Token
NewVersioned creates a Token with the supplied version string and signing method.
func NewWithClaims ¶
func NewWithClaims(method jwt.SigningMethod, body *TokenBody) *Token
NewWithClaims mirrors jwt.NewWithClaims for compatibility.
func Parse ¶
Parse decodes tokenString and verifies the signature using keyFunc. It returns the parsed Token if verification succeeds.
func (*Token) SignedString ¶
SignedString marshals the token and returns a signed compact string. The provided key is passed to the signing method.
type TokenBody ¶
type TokenBody struct {
Iss string `protobuf:"bytes,1,opt,name=iss,proto3" json:"iss,omitempty"`
Sub string `protobuf:"bytes,2,opt,name=sub,proto3" json:"sub,omitempty"`
Aud string `protobuf:"bytes,3,opt,name=aud,proto3" json:"aud,omitempty"`
Exp int64 `protobuf:"varint,4,opt,name=exp,proto3" json:"exp,omitempty"`
Nbf int64 `protobuf:"varint,5,opt,name=nbf,proto3" json:"nbf,omitempty"`
Iat int64 `protobuf:"varint,6,opt,name=iat,proto3" json:"iat,omitempty"`
Jti string `protobuf:"bytes,7,opt,name=jti,proto3" json:"jti,omitempty"`
Payload *structpb.Struct `protobuf:"bytes,8,opt,name=payload,proto3" json:"payload,omitempty"`
// contains filtered or unexported fields
}
func (*TokenBody) Descriptor
deprecated
func (*TokenBody) GetPayload ¶
func (*TokenBody) ProtoMessage ¶
func (*TokenBody) ProtoMessage()
func (*TokenBody) ProtoReflect ¶
func (x *TokenBody) ProtoReflect() protoreflect.Message
type TokenHeader ¶
type TokenHeader struct {
Alg string `protobuf:"bytes,1,opt,name=alg,proto3" json:"alg,omitempty"`
Version string `protobuf:"bytes,2,opt,name=version,proto3" json:"version,omitempty"`
// contains filtered or unexported fields
}
func (*TokenHeader) Descriptor
deprecated
func (*TokenHeader) Descriptor() ([]byte, []int)
Deprecated: Use TokenHeader.ProtoReflect.Descriptor instead.
func (*TokenHeader) GetAlg ¶
func (x *TokenHeader) GetAlg() string
func (*TokenHeader) GetVersion ¶
func (x *TokenHeader) GetVersion() string
func (*TokenHeader) ProtoMessage ¶
func (*TokenHeader) ProtoMessage()
func (*TokenHeader) ProtoReflect ¶
func (x *TokenHeader) ProtoReflect() protoreflect.Message
func (*TokenHeader) Reset ¶
func (x *TokenHeader) Reset()
func (*TokenHeader) String ¶
func (x *TokenHeader) String() string