Documentation
¶
Index ¶
- type Config
- func (c *Config) BindFlags(fs *bootflag.FlagSet)
- func (c *Config) Parse() (err error)
- func (c *Config) SetAudience(aud string)
- func (c *Config) SetExpiresAt(exp int64)
- func (c *Config) SetId(id string)
- func (c *Config) SetIssueAt(isa int64)
- func (c *Config) SetIssuer(iss string)
- func (c *Config) SetNotBefore(nbf int64)
- func (c *Config) SetSubject(sub string)
- func (c Config) Standardize() (claims jwt.StandardClaims)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// Structured version of Claims Section, as referenced at
// https://tools.ietf.org/html/rfc7519#section-4.1
// See examples for how to use this with your own claim types
Audience string `json:"aud,omitempty" yaml:"aud,omitempty"`
// The "exp" (expiration time) claim identifies the expiration time on
// or after which the JWT MUST NOT be accepted for processing. The
// processing of the "exp" claim requires that the current date/time
// MUST be before the expiration date/time listed in the "exp" claim.
// Implementers MAY provide for some small leeway, usually no more than
// a few minutes, to account for clock skew. Its value MUST be a number
// containing a NumericDate value. Use of this claim is OPTIONAL.
ExpiresAt int64 `json:"exp,omitempty" yaml:"exp,omitempty"`
// The "jti" (JWT ID) claim provides a unique identifier for the JWT.
// The identifier value MUST be assigned in a manner that ensures that
// there is a negligible probability that the same value will be
// accidentally assigned to a different data object; if the application
// uses multiple issuers, collisions MUST be prevented among values
// produced by different issuers as well. The "jti" claim can be used
// to prevent the JWT from being replayed. The "jti" value is a case-
// sensitive string. Use of this claim is OPTIONAL.
Id string `json:"jti,omitempty" yaml:"jti,omitempty"`
// The "iat" (issued at) claim identifies the time at which the JWT was
// issued. This claim can be used to determine the age of the JWT. Its
// value MUST be a number containing a NumericDate value. Use of this
// claim is OPTIONAL.
IssuedAt int64 `json:"iat,omitempty" yaml:"iat,omitempty"`
// The "iss" (issuer) claim identifies the principal that issued the
// JWT. The processing of this claim is generally application specific.
// The "iss" value is a case-sensitive string containing a StringOrURI
// value. Use of this claim is OPTIONAL.
Issuer string `json:"iss,omitempty" yaml:"iss,omitempty"`
// The "nbf" (not before) claim identifies the time before which the JWT
// MUST NOT be accepted for processing. The processing of the "nbf"
// claim requires that the current date/time MUST be after or equal to
// the not-before date/time listed in the "nbf" claim. Implementers MAY
// provide for some small leeway, usually no more than a few minutes, to
// account for clock skew. Its value MUST be a number containing a
// NumericDate value. Use of this claim is OPTIONAL.
NotBefore int64 `json:"nbf,omitempty" yaml:"nbf,omitempty"`
// The "sub" (subject) claim identifies the principal that is the
// subject of the JWT. The claims in a JWT are normally statements
// about the subject. The subject value MUST either be scoped to be
// locally unique in the context of the issuer or be globally unique.
// The processing of this claim is generally application specific. The
// "sub" value is a case-sensitive string containing a StringOrURI
// value. Use of this claim is OPTIONAL.
Subject string `json:"sub,omitempty" yaml:"sub,omitempty"`
// Expiration is the expiration for a JWT token, which is used when the ExpiresAt field is 0
Expiration time.Duration `json:"expiration" yaml:"expiration"`
// PrivateKeyFile is used to generate JWT token, if this field is specified,
// PrivateKey will be overwrite by the file content.
PrivateKeyFile string `json:"private-key-file" yaml:"private-key-file"`
// PrivateKey is used to generate JWT token
PrivateKey string `json:"private-key" yaml:"private-key"`
// PublicKeyFile is used to generate JWT token, if this field is specified,
// PublicKey will be overwrite by the file content.
PublicKeyFile string `json:"public-key-file" yaml:"public-key-file"`
// PublicKey is used to generate JWT token
PublicKey string `json:"public-key" yaml:"public-key"`
// Method is the algorithm used to sign the JWT token
Method string `json:"method" yaml:"method"`
// CustomBindFlagsFunc defines custom bind flags behaviour for structure,
// if CustomBindFlagsFunc is nil, default bind flags behaviour will be used
CustomBindFlagsFunc func(fs *bootflag.FlagSet) `json:"-" yaml:"-"`
// CustomParseFunc defines custom parse behaviour for structure,
// if CustomParseFunc is nil, default parse behaviour will be used
CustomParseFunc func() (err error) `json:"-" yaml:"-"`
}
Config is the configuration for JWT standard claims and some other extension fields.
func (*Config) SetAudience ¶
func (*Config) SetExpiresAt ¶
func (*Config) SetIssueAt ¶
func (*Config) SetNotBefore ¶
func (*Config) SetSubject ¶
func (Config) Standardize ¶
func (c Config) Standardize() (claims jwt.StandardClaims)
Click to show internal directories.
Click to hide internal directories.