auth0

package
v0.0.0-...-c45b289 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CtxAuthenticated = "authenticated"
	CtxAudience      = "audience"
	CtxUserID        = "user_id"
	CtxPersonID      = "person_id"
	CtxIsBCCMember   = "bcc_member"
)

Ctx keys

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client is the auth client

func New

func New(config Config) *Client

New creates a new auth client with the given config

func (*Client) GetToken

func (c *Client) GetToken(ctx context.Context, audience string) (string, error)

GetToken returns a token to be used towards other apis with the client credentials

func (*Client) GetUser

func (c *Client) GetUser(ctx context.Context, sub string) (UserInfo, error)

GetUser returns userinfo for a specific subject

func (*Client) SendVerificationEmail

func (c *Client) SendVerificationEmail(ctx context.Context, sub string) error

SendVerificationEmail sends a verification email to the specified user

func (*Client) UpdateUser

func (c *Client) UpdateUser(ctx context.Context, sub string, info UserInfo, metadata UserMetadata) (UserInfo, error)

UpdateUser updates user

func (*Client) ValidateToken

func (c *Client) ValidateToken() gin.HandlerFunc

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

type Config

type Config struct {
	ClientID           string
	ClientSecret       string
	Domain             string
	ManagementAudience string
	Audiences          []string
}

Config is the configuration for the client

type UserInfo

type UserInfo struct {
	UserId        string `json:"user_id"`
	Email         string `json:"email"`
	EmailVerified bool   `json:"email_verified"`
	Username      string `json:"username"`
	PhoneNumber   string `json:"phone_number"`
	PhoneVerified bool   `json:"phone_verified"`
	CreatedAt     string `json:"created_at"`
	UpdatedAt     string `json:"updated_at"`
	Identities    []struct {
		Connection string `json:"connection"`
		UserId     string `json:"user_id"`
		Provider   string `json:"provider"`
		IsSocial   bool   `json:"isSocial"`
	} `json:"identities"`
	AppMetadata struct {
	} `json:"app_metadata"`
	UserMetadata map[string]string `json:"user_metadata"`
	Picture      string            `json:"picture"`
	Name         string            `json:"name"`
	Nickname     string            `json:"nickname"`
	Multifactor  []string          `json:"multifactor"`
	LastIp       string            `json:"last_ip"`
	LastLogin    string            `json:"last_login"`
	LoginsCount  int               `json:"logins_count"`
	Blocked      bool              `json:"blocked"`
	GivenName    string            `json:"given_name"`
	FamilyName   string            `json:"family_name"`
}

UserInfo contains information about a user

func (UserInfo) CompletedRegistration

func (info UserInfo) CompletedRegistration() bool

CompletedRegistration returns true if the user has completed registration

type UserMetadata

type UserMetadata struct {
	BirthYear       string `json:"birth_year"`
	MediaSubscriber string `json:"media_subscriber"`
}

UserMetadata is the user metadata

Jump to

Keyboard shortcuts

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