auth

package
v0.0.0-...-c9a4f57 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2026 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CallbackRequest

type CallbackRequest struct {
	Code         string `json:"code"`
	CodeVerifier string `json:"code_verifier"`
}

CallbackRequest is the JSON body for the callback request.

type Config

type Config struct {
	GoogleClientID     string
	GoogleClientSecret string
	RedirectURL        string
	PrivateKeyPEM      string
	AllowedGoogleIDs   []string
}

Config holds the parameters needed to create a Handler.

type ErrorResponse

type ErrorResponse struct {
	Error string `json:"error"`
}

ErrorResponse is the standard error JSON we return.

type GoogleUserInfo

type GoogleUserInfo struct {
	Sub   string `json:"sub"`
	Email string `json:"email"`
}

GoogleUserInfo holds the fields we extract from the verified Google ID token.

type Handler

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

Handler serves the Google OAuth2 login flow and issues JWTs.

func NewHandler

func NewHandler(cfg Config) (*Handler, error)

NewHandler creates an auth Handler from the given config.

func (*Handler) RegisterRoutes

func (h *Handler) RegisterRoutes(mux *http.ServeMux)

RegisterRoutes mounts /auth/login and /auth/callback on the given mux.

type IDTokenValidator

type IDTokenValidator interface {
	Validate(ctx context.Context, idToken string, audience string) (*idtoken.Payload, error)
}

IDTokenValidator validates a Google ID token and returns the payload.

type TokenExchanger

type TokenExchanger interface {
	Exchange(ctx context.Context, code string, opts ...oauth2.AuthCodeOption) (*oauth2.Token, error)
}

TokenExchanger exchanges an authorization code for an OAuth2 token.

type TokenResponse

type TokenResponse struct {
	Token string `json:"token"`
}

TokenResponse is the JSON returned to the client after successful login.

Jump to

Keyboard shortcuts

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