token

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 2, 2018 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClaimSet

type ClaimSet struct {
	Iss           string `json:"iss"`             // email address of the client_id of the application making the access token request
	Scope         string `json:"scope,omitempty"` // space-delimited list of the permissions the application requests
	Aud           string `json:"aud"`             // descriptor of the intended target of the assertion (Optional).
	Azp           string `json:"azp"`
	Exp           int64  `json:"exp"`           // the expiration time of the assertion (seconds since Unix epoch)
	Iat           int64  `json:"iat"`           // the time the assertion was issued (seconds since Unix epoch)
	Typ           string `json:"typ,omitempty"` // token type (Optional).
	Sub           string `json:"sub,omitempty"` // Email for which the application is requesting delegated access (Optional).
	Email         string `json:"email"`
	EmailVerified bool   `json:"email_verified"`
}

ClaimSet represents claim set

type IDToken

type IDToken struct {
	// contains filtered or unexported fields
}

IDToken represents JWT token

func NewIDToken

func NewIDToken(jwt string) (*IDToken, error)

NewIDToken creates a new IDToken from the jwt string

func (*IDToken) CheckTime

func (t *IDToken) CheckTime() bool

CheckTime checks if the expiry time (exp) of the ID token has not passed

func (*IDToken) GetClaimSet

func (t *IDToken) GetClaimSet() ClaimSet

GetClaimSet returns parsed claim set

func (*IDToken) GetHeader

func (t *IDToken) GetHeader() string

GetHeader returns header part of the token

func (*IDToken) GetJWT

func (t *IDToken) GetJWT() string

GetJWT returns raw token

func (*IDToken) GetPayload

func (t *IDToken) GetPayload() string

GetPayload returns payload part of the token

type Retriever

type Retriever struct {
	// contains filtered or unexported fields
}

Retriever is a Google ID Token retriever.

func NewRetriever

func NewRetriever(clientID string) *Retriever

NewRetriever creates a new Google ID Token retriever

func (*Retriever) GetIDToken

func (r *Retriever) GetIDToken(ctx context.Context) (*IDToken, error)

GetIDToken retrieves a cached token. If the ID token is not found or is expired a new one is retrieved and cached

func (*Retriever) GetNewIDToken

func (r *Retriever) GetNewIDToken(ctx context.Context) (*IDToken, error)

GetNewIDToken retrieves a new ID token and stores it in the cache

type Verifier

type Verifier struct {
	// contains filtered or unexported fields
}

Verifier represents a Google Token verifier which caches retrieved Google's public keys. As these keys are regularly rotated, the user should determine when to retrieve them again

func NewVerifier

func NewVerifier() *Verifier

NewVerifier creates a new Google Token verifier

func (*Verifier) ResetCerts

func (v *Verifier) ResetCerts()

ResetCerts resets the caches Google's public keys. They will be retrieved during next ID token verification.

func (*Verifier) VerifyIDToken

func (v *Verifier) VerifyIDToken(ctx context.Context, jwt string, audience string) error

VerifyIDToken verifies the google ID token. See also https://developers.google.com/identity/sign-in/web/backend-auth

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL