auth

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2026 License: MIT Imports: 17 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

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

API describes dependencies for auth endpoints

func NewAPI

func NewAPI(log *zap.Logger, googleIDTokenClient GoogleIDTokenClient, githubOAuthClient GitHubOAuthClient, userFacade UserFacade, cfg APICfg) (*API, error)

NewAPI return new instance of auth api

func (*API) DeleteAccount added in v1.3.0

func (a *API) DeleteAccount(c fiber.Ctx) error

DeleteAccount deletes user account and clears refresh token cookie

func (*API) GitHubOAuth added in v1.3.0

func (a *API) GitHubOAuth(c fiber.Ctx) error

GitHubOAuth signs in or signs up user with GitHub authorization code, returns access token and sets refresh token cookie

func (*API) GoogleOAuth added in v1.3.0

func (a *API) GoogleOAuth(c fiber.Ctx) error

GoogleOAuth signs in or signs up user with Google ID token, returns access token and sets refresh token cookie

func (*API) Logout added in v1.3.0

func (a *API) Logout(c fiber.Ctx) error

Logout revokes refresh token from cookie if present and clears refresh token cookie

func (*API) RefreshToken added in v1.3.0

func (a *API) RefreshToken(c fiber.Ctx) error

RefreshToken exchanges refresh token cookie for new access token and rotates refresh token cookie

func (*API) ResendVerificationEmail added in v1.3.0

func (a *API) ResendVerificationEmail(c fiber.Ctx) error

ResendVerificationEmail queues email verification code for asynchronous delivery

func (*API) SignIn added in v1.3.0

func (a *API) SignIn(c fiber.Ctx) error

SignIn authenticates user with username and password, returns access token and sets refresh token cookie

func (*API) SignUp added in v1.3.0

func (a *API) SignUp(c fiber.Ctx) error

SignUp creates new user account, returns access token and sets refresh token cookie

func (*API) UpdateProfile added in v1.3.0

func (a *API) UpdateProfile(c fiber.Ctx) error

UpdateProfile updates user name and/or password, returns new access token and sets refresh token cookie

func (*API) VerifyEmail added in v1.3.0

func (a *API) VerifyEmail(c fiber.Ctx) error

VerifyEmail verifies user email with code sent via email, returns new access token and sets refresh token cookie

type APICfg

type APICfg struct {
	RefreshTokenCookieSameSite string
	RefreshTokenCookieSecure   bool
	ContactEmail               string
}

APICfg describes configuration for auth api

type GitHubOAuthClient

type GitHubOAuthClient interface {
	ExchangeCodeForUser(ctx context.Context, code string) (githubapi.UserInfo, error)
}

GitHubOAuthClient provides methods for GitHub OAuth authentication

type GoogleIDTokenClient

type GoogleIDTokenClient interface {
	ValidateIDToken(ctx context.Context, idToken string) (*idtoken.Payload, error)
}

GoogleIDTokenClient provides methods for validating Google ID tokens

type UserFacade

type UserFacade interface {
	GoogleOAuth(ctx context.Context, oauthID, email string, emailVerified bool) (model.User, error)
	GitHubOAuth(ctx context.Context, oauthID, email, username string, emailVerified bool) (model.User, error)
	DeleteUser(ctx context.Context, userID string) error
	UpdateUserProfile(ctx context.Context, userID string, params model.UpdateProfileParams) (model.User, error)
	VerifyEmail(ctx context.Context, userID string, code string) (model.User, error)
	ResendVerificationEmail(ctx context.Context, userID string) error
	SignIn(ctx context.Context, username, password string) (model.User, error)
	SignUp(ctx context.Context, username, displayName, email, password string, isPublisher bool) (model.User, error)
	CreateTokens(ctx context.Context, user model.User) (facade.TokenPair, error)
	RefreshTokens(ctx context.Context, refreshTokenStr string) (facade.TokenPair, error)
	RevokeRefreshToken(ctx context.Context, refreshTokenStr string) error
	ValidateAccessToken(tokenStr string) bool
	GetClaimsFromAccessToken(tokenStr string) (auth.Claims, error)
}

UserFacade provides methods for working with user facade

Directories

Path Synopsis
Package auth_mocks is a generated GoMock package.
Package auth_mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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