Documentation
¶
Index ¶
- Constants
- func CheckPassword(hash, password string) bool
- func ExtractPrefix(rawToken string) string
- func GenerateToken(prefix string) (string, string, string, error)
- func HashPassword(password string) (string, error)
- func HashToken(rawToken string) string
- type Service
- func (s *Service) CreateToken(ctx context.Context, userID uuid.UUID, label string) (string, *model.APIToken, error)
- func (s *Service) Login(ctx context.Context, handle, password string) (string, *model.User, error)
- func (s *Service) SetPassword(ctx context.Context, userID uuid.UUID, password string) error
- func (s *Service) ValidateToken(ctx context.Context, rawToken string) (*model.User, error)
Constants ¶
View Source
const (
DefaultPrefix = "clh_"
)
Variables ¶
This section is empty.
Functions ¶
func CheckPassword ¶
CheckPassword verifies a plaintext password against a bcrypt hash.
func ExtractPrefix ¶
ExtractPrefix extracts the prefix portion used for fast DB lookup.
func GenerateToken ¶
GenerateToken creates a new API token with the clh_ prefix. Returns (rawToken, prefix, tokenHash).
func HashPassword ¶
HashPassword hashes a plaintext password using bcrypt.
Types ¶
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func NewService ¶
func NewService(tokenRepo *repository.TokenRepo, userRepo *repository.UserRepo) *Service
func (*Service) CreateToken ¶
func (s *Service) CreateToken(ctx context.Context, userID uuid.UUID, label string) (string, *model.APIToken, error)
CreateToken generates a new API token for a user.
func (*Service) Login ¶
Login validates a handle+password, and returns a new API token for the session.
func (*Service) SetPassword ¶
SetPassword sets a user's password hash.
Click to show internal directories.
Click to hide internal directories.