Documentation
¶
Index ¶
- type AuthenticationBackend
- type AuthenticationManager
- type FacebookClient
- type GithubClient
- type GoogleBackend
- func (g *GoogleBackend) Authenticate(ctx context.Context, credentials map[string]any) (interfaces.User, error)
- func (g *GoogleBackend) LinkSocialAccount(ctx context.Context, googleUser *pkg.GoogleUser) (*models.SocialAccount, error)
- func (g *GoogleBackend) Name() string
- func (g *GoogleBackend) Priority() int
- func (g *GoogleBackend) Supports(method string) bool
- func (g *GoogleBackend) ValidateToken(ctx context.Context, tokenString string) (interfaces.User, error)
- type GoogleClient
- type LocalBackend
- func (b *LocalBackend) Authenticate(ctx context.Context, credentials map[string]any) (interfaces.User, error)
- func (b *LocalBackend) Name() string
- func (b *LocalBackend) Priority() int
- func (b *LocalBackend) Supports(method string) bool
- func (b *LocalBackend) ValidateToken(ctx context.Context, tokenString string) (interfaces.User, error)
- type SocialProviderClient
- type SocialUserInfo
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