auth

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckPassword

func CheckPassword(hash, password string) bool

CheckPassword verifies a bcrypt password hash.

func HashPassword

func HashPassword(password string) (string, error)

HashPassword hashes a password with bcrypt.

func IssueToken

func IssueToken(secret string, ttl time.Duration, userID, email, role string) (string, error)

IssueToken creates a signed HS256 JWT.

Types

type Claims

type Claims struct {
	UserID string `json:"uid"`
	Email  string `json:"email"`
	Role   string `json:"role"`
	jwt.RegisteredClaims
}

Claims are JWT claims for platform sessions.

func ParseToken

func ParseToken(secret, token string) (*Claims, error)

ParseToken validates and parses a platform JWT.

type Service

type Service struct {
	JWTSecret string
	TokenTTL  time.Duration
}

Service implements identity.TokenIssuer and identity.PasswordHasher.

func NewService

func NewService(jwtSecret string, tokenTTL time.Duration) *Service

func (*Service) Check

func (s *Service) Check(hash, password string) bool

func (*Service) Hash

func (s *Service) Hash(password string) (string, error)

func (*Service) Issue

func (s *Service) Issue(userID, email, role string) (string, error)

Jump to

Keyboard shortcuts

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