Help us shape the future of Go! Take the 2026 Go Developer Survey

auth

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const UserIDKey contextKey = "userID"

Variables

View Source
var ErrEmailExists = errors.New("email already exists")
View Source
var ErrInternalServerError = errors.New("internal server error")
View Source
var ErrInvalidEmailOrPassword = errors.New("invalid email or password")

Functions

func InsertGoogleData

func InsertGoogleData(ctx context.Context, db *pgxpool.Pool, claims claims, expiresAt time.Time) (token string, error error)

func InsertUserData

func InsertUserData(ctx context.Context, db *pgxpool.Pool, signUp signUp, expiresAt time.Time) (token string, error error)

func SignIn

func SignIn(ctx context.Context, db *pgxpool.Pool, signIn signIn, expiresAt time.Time) (token string, error error)

Types

type AuthHandler

type AuthHandler struct {
	CookieDomain string
	SecureCookie bool
	DB           *pgxpool.Pool
}

func (*AuthHandler) GetSession

func (Auth *AuthHandler) GetSession() http.HandlerFunc

func (*AuthHandler) Protected

func (Auth *AuthHandler) Protected(next http.HandlerFunc) http.HandlerFunc

func (*AuthHandler) SignIn

func (Auth *AuthHandler) SignIn() http.HandlerFunc

func (*AuthHandler) SignOut

func (Auth *AuthHandler) SignOut() http.HandlerFunc

func (*AuthHandler) SignUp

func (Auth *AuthHandler) SignUp() http.HandlerFunc

type GoogleCFG

type GoogleCFG struct {
	RedirectOrigin  string
	CookieDomain    string
	SecureCookie    bool
	Config          oauth2.Config
	IDTokenVerifier *oidc.IDTokenVerifier
	DB              *pgxpool.Pool
}

func GoogleConfig

func GoogleConfig(clientID string, clientSecret string, redirectURL string) (*GoogleCFG, error)

func (*GoogleCFG) GoogleCallback

func (cfg *GoogleCFG) GoogleCallback() http.HandlerFunc

func (*GoogleCFG) GoogleSignIn

func (cfg *GoogleCFG) GoogleSignIn() http.HandlerFunc

type User

type User struct {
	ID            string    `json:"id"`
	Email         string    `json:"email"`
	Name          string    `json:"name"`
	EmailVerified bool      `json:"emailVerified"`
	CreatedAt     time.Time `json:"createdAt"`
}

Jump to

Keyboard shortcuts

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