Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // InvalidTokenErr error for an invalid Authorization header value. InvalidTokenErr = NewError(http.StatusUnauthorized, "Invalid token") // MissingTokenErr error for missing Authorization bearer token. MissingTokenErr = NewError(http.StatusBadRequest, "Missing bearer token") // InternalServerErr error for any internal server errors. InternalServerErr = NewError(http.StatusInternalServerError, "Internal server error") )
Functions ¶
func BearerToken ¶
BearerToken function returns the bearer token in an Authorization HTTP header.
func WriteError ¶
WriteError convenience function for writing error responses.
Types ¶
type Claims ¶
type Claims struct {
Validator *Validator
Issuer string `json:"iss,omitempty"`
Subject string `json:"sub,omitempty"`
Audience string `json:"aud,omitempty"`
ExpirationTime Timestamp `json:"exp,omitempty"`
NotBefore Timestamp `json:"nbf,omitempty"`
IssuedAt Timestamp `json:"iat,omitempty"`
ID string `json:"jti,omitempty"`
}
Claims represents a JWT claims set. Includes standard keys with additional Google claims.
type Error ¶
type Error struct {
Message string
// contains filtered or unexported fields
}
Error custom error type.
type GoogleIdentityClaims ¶
type GoogleIdentityClaims struct {
*Claims
Email string `json:"email,omitempty"`
EmailVerified bool `json:"email_verified,omitempty"`
Name string `json:"name,omitempty"`
GivenName string `json:"given_name,omitempty"`
FamilyName string `json:"family_mame,omitempty"`
Locale string `json:"locale,omitempty"`
Picture string `json:"picture,omitempty"`
AuthorizedPresenter string `json:"azp,omitempty"`
AccessTokenHash string `json:"at_hash,omitempty"`
}
GoogleIdentityClaims represents Google JWT claims and extends Claims.
type JWSVerifyer ¶
type JWSVerifyer struct {
*jose.JsonWebKeySet
// contains filtered or unexported fields
}
JWSVerifyer struct verifies JSON Web Signatures against a JWK Set.
func NewJWSVerifyer ¶
func NewJWSVerifyer(url string) (*JWSVerifyer, error)
NewJWSVerifyer constructs a JWSVerifyer.
func (*JWSVerifyer) UpdateKeySet ¶
func (v *JWSVerifyer) UpdateKeySet() error
UpdateKeySet updates the JWK Set.
type Timestamp ¶
Timestamp custom time.Time type with MarshalJSON and UnmarshalJSON methods.
func (*Timestamp) MarshalJSON ¶
MarshalJSON handles Timestamp to byte array conversion.
func (*Timestamp) UnmarshalJSON ¶
UnmarshalJSON handles JSON timestamp string to Timestamp type.
type TokenValidator ¶
type TokenValidator struct {
Claims *Validator
Signatures *JWSVerifyer
}
TokenValidator convenience container for JWSVerifyer and Claimer.
func GoogleTokenValidator ¶
func GoogleTokenValidator(aud ...string) (*TokenValidator, error)
GoogleTokenValidator constructor for a Google TokenValidator.