backends

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: MIT Imports: 19 Imported by: 1 module, 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 AuthenticationBackend

type AuthenticationBackend interface {
	// Authenticate attempts to authenticate a user with the given credentials
	Authenticate(ctx context.Context, credentials map[string]any) (interfaces.User, error)
	// ValidateToken validates a token and returns the associated user
	ValidateToken(ctx context.Context, token string) (interfaces.User, error)
}

AuthenticationBackend defines the interface for authentication backends

type AuthenticationManager

type AuthenticationManager interface {
	RegisterBackend(name string, backend AuthenticationBackend)
	Authenticate(ctx context.Context, credentials map[string]any) (interfaces.User, error)
	ValidateToken(ctx context.Context, token string) (interfaces.User, error)
}

AuthenticationManager manages multiple authentication backends

func NewAuthenticationManager

func NewAuthenticationManager(eventEmitter emitter.EventEmitter) AuthenticationManager

NewAuthenticationManager creates a new authentication manager

type FacebookClient

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

FacebookClient implements Facebook OAuth authentication

func NewFacebookClient

func NewFacebookClient(config config.SocialProviderConfig) *FacebookClient

func (*FacebookClient) GetUserInfo

func (c *FacebookClient) GetUserInfo(accessToken string) (*SocialUserInfo, error)

type GithubClient

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

GithubClient implements Github OAuth authentication

func NewGithubClient

func NewGithubClient(config config.SocialProviderConfig) *GithubClient

func (*GithubClient) GetUserInfo

func (c *GithubClient) GetUserInfo(accessToken string) (*SocialUserInfo, error)

type GoogleBackend

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

func NewGoogleBackend

func NewGoogleBackend(
	socialRepo interfaces.SocialAccountRepository,
	userRepo interfaces.UserRepository,
	tokenIssuer interfaces.TokenIssuer,
	googleSignin interfaces.GoogleSignin,
) *GoogleBackend

func (*GoogleBackend) Authenticate

func (g *GoogleBackend) Authenticate(
	ctx context.Context,
	credentials map[string]any,
) (interfaces.User, error)

func (*GoogleBackend) LinkSocialAccount

func (g *GoogleBackend) LinkSocialAccount(ctx context.Context, googleUser *pkg.GoogleUser) (*models.SocialAccount, error)

func (*GoogleBackend) Name

func (g *GoogleBackend) Name() string

func (*GoogleBackend) Priority

func (g *GoogleBackend) Priority() int

func (*GoogleBackend) Supports

func (g *GoogleBackend) Supports(method string) bool

func (*GoogleBackend) ValidateToken

func (g *GoogleBackend) ValidateToken(
	ctx context.Context,
	tokenString string,
) (interfaces.User, error)

type GoogleClient

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

GoogleClient implements Google OAuth2 authentication

func NewGoogleClient

func NewGoogleClient(config config.SocialProviderConfig) *GoogleClient

func (*GoogleClient) GetUserInfo

func (c *GoogleClient) GetUserInfo(accessToken string) (*SocialUserInfo, error)

type LocalBackend

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

LocalBackend implements the AuthenticationBackend interface for local authentication

func NewLocalBackend

func NewLocalBackend(userRepo interfaces.UserRepository, tokenIssuer interfaces.TokenIssuer) *LocalBackend

NewLocalBackend creates a new local authentication backend

func (*LocalBackend) Authenticate

func (b *LocalBackend) Authenticate(ctx context.Context, credentials map[string]any) (interfaces.User, error)

Authenticate authenticates a user with username/email and password

func (*LocalBackend) Name

func (b *LocalBackend) Name() string

Name returns the name of the backend

func (*LocalBackend) Priority

func (b *LocalBackend) Priority() int

Priority returns the priority of the backend

func (*LocalBackend) Supports

func (b *LocalBackend) Supports(method string) bool

Supports returns whether the backend supports a given authentication method

func (*LocalBackend) ValidateToken

func (b *LocalBackend) ValidateToken(ctx context.Context, tokenString string) (interfaces.User, error)

ValidateToken validates a JWT token and returns the associated user

type SocialProviderClient

type SocialProviderClient interface {
	GetUserInfo(accessToken string) (*SocialUserInfo, error)
}

SocialProviderClient defines the interface for social provider API clients

type SocialUserInfo

type SocialUserInfo struct {
	ID    string
	Email string
	Name  string
	Raw   map[string]interface{}
}

SocialUserInfo represents common user info from social providers

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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