google

package
v0.0.0-...-68e8b16 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GoogleIdTokenPayload

type GoogleIdTokenPayload struct {
	Issuer   string                 `json:"iss"`
	Audience string                 `json:"aud"`
	Expires  int64                  `json:"exp"`
	IssuedAt int64                  `json:"iat"`
	Subject  string                 `json:"sub,omitempty"`
	Claims   map[string]interface{} `json:"-"`
}

func ParsePayload

func ParsePayload(idToken string) (*GoogleIdTokenPayload, error)

ParsePayload parses the given token and returns its payload.

Warning: This function does not validate the token prior to parsing it.

ParsePayload is primarily meant to be used to inspect a token's payload. This is useful when validation fails and the payload needs to be inspected.

Note: A successful Validate() invocation with the same token will return an identical payload.

func (*GoogleIdTokenPayload) GetClaims

func (p *GoogleIdTokenPayload) GetClaims() *GoogleUserClaims

type GoogleUserClaims

type GoogleUserClaims struct {
	Email         string
	EmailVerified bool
	Id            string
	Name          string
	Picture       string
	FirstName     string
	LastName      string
}

type Validator

type Validator struct {
}

Validator provides a way to validate Google ID Tokens

func NewValidator

func NewValidator() *Validator

func (*Validator) ValidateToken

func (v *Validator) ValidateToken(idToken string, audience string) (*GoogleIdTokenPayload, error)

Validate is used to validate the provided idToken with a known Google cert URL. If audience is not empty the audience claim of the Token is validated. Upon successful validation a parsed token Payload is returned allowing the caller to valdate any additional claims.i

Jump to

Keyboard shortcuts

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