auth

package
v0.25.0 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnsureValidToken added in v0.25.0

func EnsureValidToken() func(next http.Handler) http.Handler

EnsureValidToken is a middleware that will check the validity of our JWT.

func GetUserProfile added in v0.25.0

func GetUserProfile(id string) (map[string]interface{}, error)

Types

type CustomClaims added in v0.25.0

type CustomClaims struct {
	Scope   string `json:"scope"`
	Subject string `json:"sub"`
}

CustomClaims contains custom data we want from the token.

func (CustomClaims) Validate added in v0.25.0

func (c CustomClaims) Validate(ctx context.Context) error

Validate does nothing for this example, but we need it to satisfy validator.CustomClaims interface.

type Profile

type Profile struct {
	GivenName  string  `json:"given_name"`
	Picture    string  `json:"picture"`
	Issuer     string  `json:"iss"`
	Audience   string  `json:"aud"`
	IssuedAt   float64 `json:"iat"`
	Subject    string  `json:"sub"`
	FamilyName string  `json:"family_name"`
	Nickname   string  `json:"nickname"`
	Name       string  `json:"name"`
	Locale     string  `json:"locale"`
	UpdatedAt  string  `json:"updated_at"`
	ExpiresAt  float64 `json:"exp"`
	SessionID  string  `json:"sid"`
}

type Token

type Token struct {
	Kind      string
	Token     string
	Scopes    []string
	ExpiresAt time.Time
}

func GetToken

func GetToken() (*Token, error)

type UserProfile

type UserProfile struct {
	AppMetadata   map[string]interface{} `json:"app_metadata"`
	UserMetadata  map[string]interface{} `json:"user_metadata"`
	Email         string                 `json:"email"`
	EmailVerified bool                   `json:"email_verified"`
}

Jump to

Keyboard shortcuts

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