auth

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthProvider

type AuthProvider interface {
	// HandleLogin is a method that will be implemented by the auth provider
	HandleLogin(ctx context.Context, username, password string) (*entities.User, string, error)
	// ValidateToken is a method that will be implemented by the auth provider
	ValidateToken(ctx context.Context, token string) (bool, error)
	// ValidateUserPassword is a method that will be implemented by the auth provider
	ValidateUserPassword(ctx context.Context, username, password string) (user *entities.User, valid bool, err error)
	// RefreshToken is a method that will be implemented by the auth provider
	RefreshToken(ctx context.Context, token string) (string, error)
	// GenerateToken is a method that will be implemented by the auth provider
	GenerateToken(ctx context.Context, user *entities.User) (string, error)
	// NewTokenAuth is a method that will be implemented by the auth provider
	NewTokenAuth() *jwtauth.JWTAuth
}

func NewAuthProvider

func NewAuthProvider(service *services.OrganizationService) (AuthProvider, error)

NewAuthProvider creates a new AuthProvider

type AuthProviderImpl

type AuthProviderImpl struct {
	JWTSecret string
	JWTAuth   *jwtauth.JWTAuth
	Service   *services.OrganizationService
}

AuthProviderImpl is the default implementation of the AuthProvider interface

func (*AuthProviderImpl) GenerateToken

func (a *AuthProviderImpl) GenerateToken(ctx context.Context, user *entities.User) (string, error)

GetToken is a method that will be implemented by the auth provider

func (*AuthProviderImpl) HandleLogin

func (a *AuthProviderImpl) HandleLogin(ctx context.Context, username, password string) (user *entities.User, token string, err error)

HandleLogin is a method that will be implemented by the auth provider

func (*AuthProviderImpl) NewTokenAuth

func (a *AuthProviderImpl) NewTokenAuth() *jwtauth.JWTAuth

NewTokenAuth is a method that will be implemented by the auth provider

func (*AuthProviderImpl) RefreshToken

func (a *AuthProviderImpl) RefreshToken(ctx context.Context, token string) (string, error)

RefreshToken is a method that will be implemented by the auth provider

func (*AuthProviderImpl) ValidateToken

func (a *AuthProviderImpl) ValidateToken(ctx context.Context, token string) (bool, error)

ValidateToken is a method that will be implemented by the auth provider

func (*AuthProviderImpl) ValidateUserPassword

func (a *AuthProviderImpl) ValidateUserPassword(ctx context.Context, username, password string) (user *entities.User, valid bool, err error)

ValidateUserPassword is a method that will be implemented by the auth provider

Jump to

Keyboard shortcuts

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