Documentation ¶
Overview ¶
Package jwt implements JSON Web Token (JWT) specification.
Index ¶
- type Claims
- type CommonClaims
- func (p *CommonClaims) Decode(input string) error
- func (p *CommonClaims) Encode(w io.Writer) error
- func (p *CommonClaims) GetAudience() string
- func (p *CommonClaims) GetExpireAt() time.Time
- func (p *CommonClaims) GetIssuedAt() time.Time
- func (p *CommonClaims) GetIssuer() string
- func (p *CommonClaims) GetNotBefore() time.Time
- func (p *CommonClaims) GetSubject() string
- func (p *CommonClaims) HasClientScopes(scopes ...string) bool
- func (p *CommonClaims) HasUserScopes(scopes ...string) bool
- func (mj *CommonClaims) MarshalJSON() ([]byte, error)
- func (mj *CommonClaims) MarshalJSONBuf(buf fflib.EncodingBuffer) error
- func (p *CommonClaims) SetExpireAt(dt time.Time)
- func (p *CommonClaims) SetIssuedAt(dt time.Time)
- func (p *CommonClaims) SetIssuer(issuer string)
- func (p *CommonClaims) SetNotBefore(dt time.Time)
- func (uj *CommonClaims) UnmarshalJSON(input []byte) error
- func (uj *CommonClaims) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error
- func (p *CommonClaims) Validate() bool
- type GoogleClaims
- func (gc *GoogleClaims) Decode(input string) error
- func (gc *GoogleClaims) Encode(w io.Writer) error
- func (gc *GoogleClaims) GetAudience() string
- func (gc *GoogleClaims) GetExpireAt() time.Time
- func (gc *GoogleClaims) GetIssuedAt() time.Time
- func (gc *GoogleClaims) GetIssuer() string
- func (*GoogleClaims) GetNotBefore() time.Time
- func (gc *GoogleClaims) GetSubject() string
- func (mj *GoogleClaims) MarshalJSON() ([]byte, error)
- func (mj *GoogleClaims) MarshalJSONBuf(buf fflib.EncodingBuffer) error
- func (gc *GoogleClaims) SetExpireAt(dt time.Time)
- func (gc *GoogleClaims) SetIssuedAt(dt time.Time)
- func (gc *GoogleClaims) SetIssuer(issuer string)
- func (*GoogleClaims) SetNotBefore(dt time.Time)
- func (uj *GoogleClaims) UnmarshalJSON(input []byte) error
- func (uj *GoogleClaims) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error
- func (gc *GoogleClaims) Validate() bool
- type UnixTime
- type UserClaims
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Claims ¶
type Claims interface { Decode(string) error Encode(io.Writer) error Validate() bool json.Marshaler json.Unmarshaler }
A Claims set represents a JSON object whose members are the claims conveyed by the JWT.
type CommonClaims ¶
type CommonClaims struct { ID string `json:"jti,omitempty"` Issuer string `json:"iss,omitempty"` Subject string `json:"sub,omitempty"` Audience string `json:"aud,omitempty"` ExpireAt UnixTime `json:"exp"` NotBefore UnixTime `json:"nbf,omitempty"` IssuedAt UnixTime `json:"iat,omitempty"` Scopes []string `json:"scopes,omitempty"` User *UserClaims `json:"user,omitempty"` }
A CommonClaims set represents a JSON object whose members are the claims conveyed by the JWT.
func (*CommonClaims) Decode ¶
func (p *CommonClaims) Decode(input string) error
Decode specified encoded token to current instance.
func (*CommonClaims) Encode ¶
func (p *CommonClaims) Encode(w io.Writer) error
Encode current instance to specified writer.
func (*CommonClaims) GetAudience ¶
func (p *CommonClaims) GetAudience() string
GetAudience returns the recipients that the JWT is intended for.
func (*CommonClaims) GetExpireAt ¶
func (p *CommonClaims) GetExpireAt() time.Time
GetExpireAt returns the token expiration date.
func (*CommonClaims) GetIssuedAt ¶
func (p *CommonClaims) GetIssuedAt() time.Time
GetIssuedAt returns the token issue date.
func (*CommonClaims) GetIssuer ¶
func (p *CommonClaims) GetIssuer() string
GetIssuer returns the token issuer.
func (*CommonClaims) GetNotBefore ¶
func (p *CommonClaims) GetNotBefore() time.Time
GetNotBefore returns the minimal date required to use current token.
func (*CommonClaims) GetSubject ¶
func (p *CommonClaims) GetSubject() string
GetSubject returns the principal that is the subject of the JWT.
func (*CommonClaims) HasClientScopes ¶
func (p *CommonClaims) HasClientScopes(scopes ...string) bool
HasClientScopes determines whether any of specified client scopes exists on current instance.
func (*CommonClaims) HasUserScopes ¶
func (p *CommonClaims) HasUserScopes(scopes ...string) bool
HasUserScopes determines whether any of specified user scopes exists on current instance.
func (*CommonClaims) MarshalJSON ¶
func (mj *CommonClaims) MarshalJSON() ([]byte, error)
func (*CommonClaims) MarshalJSONBuf ¶
func (mj *CommonClaims) MarshalJSONBuf(buf fflib.EncodingBuffer) error
func (*CommonClaims) SetExpireAt ¶
func (p *CommonClaims) SetExpireAt(dt time.Time)
SetExpireAt defines the token expiration date.
func (*CommonClaims) SetIssuedAt ¶
func (p *CommonClaims) SetIssuedAt(dt time.Time)
SetIssuedAt defines the token issue date.
func (*CommonClaims) SetIssuer ¶
func (p *CommonClaims) SetIssuer(issuer string)
SetIssuer defines the token issuer.
func (*CommonClaims) SetNotBefore ¶
func (p *CommonClaims) SetNotBefore(dt time.Time)
SetNotBefore defines the minimal date required to use current token.
func (*CommonClaims) UnmarshalJSON ¶
func (uj *CommonClaims) UnmarshalJSON(input []byte) error
func (*CommonClaims) UnmarshalJSONFFLexer ¶
func (uj *CommonClaims) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error
func (*CommonClaims) Validate ¶
func (p *CommonClaims) Validate() bool
Validate returns whether current claims are valid.
type GoogleClaims ¶
type GoogleClaims struct { Issuer string `json:"iss"` Subject string `json:"sub"` AuthorizedParty string `json:"azp"` Audience string `json:"aud"` IssuedAt UnixTime `json:"iat"` ExpireAt UnixTime `json:"exp"` Email string `json:"email,omitempty"` EmailVerified bool `json:"email_verified,omitempty"` Name string `json:"name,omitempty"` Picture string `json:"picture,omitempty"` GivenName string `json:"given_name,omitempty"` FamilyName string `json:"family_name,omitempty"` Locale string `json:"locale,omitempty"` HostedDomain string `json:"hd,omitempty"` }
A GoogleClaims represents a JSON object from Google ID Tokens.
func (*GoogleClaims) Decode ¶
func (gc *GoogleClaims) Decode(input string) error
Decode specified encoded token to current instance.
func (*GoogleClaims) Encode ¶
func (gc *GoogleClaims) Encode(w io.Writer) error
Encode current instance to specified writer.
func (*GoogleClaims) GetAudience ¶
func (gc *GoogleClaims) GetAudience() string
GetAudience returns the recipients that the JWT is intended for.
func (*GoogleClaims) GetExpireAt ¶
func (gc *GoogleClaims) GetExpireAt() time.Time
GetExpireAt returns the token expiration date.
func (*GoogleClaims) GetIssuedAt ¶
func (gc *GoogleClaims) GetIssuedAt() time.Time
GetIssuedAt returns the token issue date.
func (*GoogleClaims) GetIssuer ¶
func (gc *GoogleClaims) GetIssuer() string
GetIssuer returns the token issuer.
func (*GoogleClaims) GetNotBefore ¶
func (*GoogleClaims) GetNotBefore() time.Time
GetNotBefore returns zero.
func (*GoogleClaims) GetSubject ¶
func (gc *GoogleClaims) GetSubject() string
GetSubject returns the principal that is the subject of the JWT.
func (*GoogleClaims) MarshalJSON ¶
func (mj *GoogleClaims) MarshalJSON() ([]byte, error)
func (*GoogleClaims) MarshalJSONBuf ¶
func (mj *GoogleClaims) MarshalJSONBuf(buf fflib.EncodingBuffer) error
func (*GoogleClaims) SetExpireAt ¶
func (gc *GoogleClaims) SetExpireAt(dt time.Time)
SetExpireAt defines the token expiration date.
func (*GoogleClaims) SetIssuedAt ¶
func (gc *GoogleClaims) SetIssuedAt(dt time.Time)
SetIssuedAt defines the token issue date.
func (*GoogleClaims) SetIssuer ¶
func (gc *GoogleClaims) SetIssuer(issuer string)
SetIssuer defines the token issuer.
func (*GoogleClaims) SetNotBefore ¶
func (*GoogleClaims) SetNotBefore(dt time.Time)
SetNotBefore does nothing.
func (*GoogleClaims) UnmarshalJSON ¶
func (uj *GoogleClaims) UnmarshalJSON(input []byte) error
func (*GoogleClaims) UnmarshalJSONFFLexer ¶
func (uj *GoogleClaims) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error
func (*GoogleClaims) Validate ¶
func (gc *GoogleClaims) Validate() bool
Validate returns whether current claims are valid.
type UnixTime ¶
type UnixTime int64
A UnixTime represents an instant in time from the number of seconds elapsed since January 1, 1970 UTC.
func NewUnixTime ¶
NewUnixTime create a new instance of UnixTime from Time.
type UserClaims ¶
type UserClaims struct { Name string `json:"name"` Email string `json:"email"` Scopes []string `json:"scopes"` Country string `json:"country,omitempty"` Tags []string `json:"tags,omitempty"` }
A UserClaims represents the user claims set embedded on main claims set.
func (*UserClaims) MarshalJSON ¶
func (mj *UserClaims) MarshalJSON() ([]byte, error)
func (*UserClaims) MarshalJSONBuf ¶
func (mj *UserClaims) MarshalJSONBuf(buf fflib.EncodingBuffer) error
func (*UserClaims) UnmarshalJSON ¶
func (uj *UserClaims) UnmarshalJSON(input []byte) error
func (*UserClaims) UnmarshalJSONFFLexer ¶
func (uj *UserClaims) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error