service

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidCredentials = errors.New("invalid credentials")
	ErrTokenExpired       = errors.New("token expired")
	ErrKeyRevoked         = errors.New("api key revoked")
)

Functions

This section is empty.

Types

type APIKeyPrincipal

type APIKeyPrincipal struct {
	KeyID  int64
	RoleID int64
}

type AuthService

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

func NewAuthService

func NewAuthService(store *config.Store, jwtSecret string) *AuthService

func (*AuthService) IssueJWT

func (s *AuthService) IssueJWT(ctx context.Context, adminID int64, email string, ttl time.Duration) (string, error)

IssueJWT creates a new signed JWT token for the given admin.

func (*AuthService) ValidateAPIKey

func (s *AuthService) ValidateAPIKey(ctx context.Context, rawKey string) (*APIKeyPrincipal, error)

ValidateAPIKey checks the provided raw API key against stored key hashes.

func (*AuthService) ValidateJWT

func (s *AuthService) ValidateJWT(ctx context.Context, tokenStr string) (*JWTPrincipal, error)

ValidateJWT verifies a JWT bearer token and returns the associated admin identity.

type JWTPrincipal

type JWTPrincipal struct {
	AdminID int64
	Email   string
}

Jump to

Keyboard shortcuts

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