backend

package
v0.32.0 Latest Latest
Warning

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

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

Documentation

Overview

https://pascalallen.medium.com/jwt-authentication-with-go-242215a9b4f8

litter-go backend

Index

Constants

This section is empty.

Variables

View Source
var (
	FlowCache         *core.Cache
	PollCache         *core.Cache
	SubscriptionCache *core.Cache
	TokenCache        *core.Cache
	UserCache         *core.Cache
)

Functions

func DumpAll added in v0.21.1

func DumpAll()

func GetGravatarURL added in v0.16.6

func GetGravatarURL(emailInput string) string

GetGravatarURL function returns the avatar image location/URL, or it defaults to a app logo.

func LoadAPIRouter added in v0.23.0

func LoadAPIRouter() chi.Router

the very main API router

func LoadAll added in v0.21.1

func LoadAll()

func NewAccessToken added in v0.23.5

func NewAccessToken(claims UserClaims, secret string) (string, error)

func NewRefreshToken added in v0.23.5

func NewRefreshToken(claims jwt.StandardClaims, secret string) (string, error)

func ParseRefreshToken added in v0.23.5

func ParseRefreshToken(refreshToken string, secret string) *jwt.StandardClaims

func RunMigrations added in v0.16.0

func RunMigrations() bool

RunMigrations is a "wrapper" function for the migration registration and execution

Types

type Logger added in v0.18.8

type Logger struct {
	// CallerID is a nickname of the user calling the API.
	CallerID string `json:"caller_id" validation:"required"`

	// Code integer is a HTTP return code.
	Code int `json:"code" validation:"required"`

	// IPAddress string is basically an user's IPv4/IPv6 address (beware of proxies).
	IPAddress string `json:"ip_address"`

	// Message string holds a custom message returned by a various HTTP handler.
	Message string `json:"message" validation:"required"`

	// Method string hold a HTTP method name.
	Method string `json:"method"`

	// Route string is the very route called by user.
	Route string `json:"route"`

	// Time property hold the actual time of the request processing.
	Time time.Time `json:"time" validation:"required"`

	// Version is the tagged version of the client's SW (compiled in).
	Version string `json:"version"`

	// WorkerName string is the name of a worker processing such request.
	WorkerName string `json:"worker_name" validation:"required"`
}

func NewLogger added in v0.23.1

func NewLogger(r *http.Request, worker string) *Logger

func (*Logger) Println added in v0.18.8

func (l *Logger) Println(msg string, code int) bool

Println formats the encoded Logger struct into an output string to stdin.

type RefreshToken added in v0.24.0

type RefreshToken string

type UserAuth

type UserAuth struct {
	User     string `json:"user_name"`
	PassHash string `json:"pass_hash"`
}

type UserClaims added in v0.23.5

type UserClaims struct {
	Nickname string      `json:"nickname"`
	User     models.User `json:"user"`
	jwt.StandardClaims
}

func ParseAccessToken added in v0.23.5

func ParseAccessToken(accessToken string, secret string) *UserClaims

Jump to

Keyboard shortcuts

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