netlifyid

package
v0.0.0-...-16adccd Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AppMetadata

type AppMetadata struct {
	Provider string   `json:"provider"`
	Roles    []string `json:"roles"`
}

type AuthService

type AuthService interface {
	AuthFromHeader(r *http.Request) (*http.Request, error)
	AuthFromCookie(r *http.Request) (*http.Request, error)
	HasRole(r *http.Request, role string) (err error)
}

func NewService

func NewService(isLambda bool) AuthService

type Identity

type Identity struct {
	Token string `json:"token"`
	URL   string `json:"url"`
}

type JWT

type JWT struct {
	Identity Identity `json:"identity"`
	SiteURL  string   `json:"site_url"`
	User     User     `json:"user"`
}

func FromContext

func FromContext(ctx context.Context) *JWT

func FromCookie

func FromCookie(r *http.Request) (id *JWT, err error)

Danger! Does not verify JWT! Do not use in insecure context.

func FromLambdaContext

func FromLambdaContext(ctx context.Context) (*JWT, error)

func (*JWT) Email

func (jwt *JWT) Email() string

func (*JWT) HasRole

func (jwt *JWT) HasRole(role string) bool

func (*JWT) Username

func (jwt *JWT) Username() string

type MockAuthService

type MockAuthService struct{}

func (MockAuthService) AuthFromCookie

func (mas MockAuthService) AuthFromCookie(r *http.Request) (*http.Request, error)

func (MockAuthService) AuthFromHeader

func (mas MockAuthService) AuthFromHeader(r *http.Request) (*http.Request, error)

func (MockAuthService) HasRole

func (mas MockAuthService) HasRole(r *http.Request, role string) error

type NetlifyAuth

type NetlifyAuth struct{}

func (NetlifyAuth) AuthFromCookie

func (as NetlifyAuth) AuthFromCookie(r *http.Request) (*http.Request, error)

func (NetlifyAuth) AuthFromHeader

func (as NetlifyAuth) AuthFromHeader(r *http.Request) (*http.Request, error)

func (NetlifyAuth) HasRole

func (as NetlifyAuth) HasRole(r *http.Request, role string) error

type User

type User struct {
	AppMetadata  AppMetadata  `json:"app_metadata"`
	Email        string       `json:"email"`
	Exp          int          `json:"exp"`
	Sub          string       `json:"sub"`
	UserMetadata UserMetadata `json:"user_metadata"`
}

type UserMetadata

type UserMetadata struct {
	FullName string `json:"full_name"`
}

Jump to

Keyboard shortcuts

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